Please note that Sahi's development and support teams do not actively monitor this. This is more a community forum. If you are a Sahi Pro user looking for commercial support, please email support @ sahipro.com with your query.

Calling JavaScript Function From SAHI Script

junaid.kochakjunaid.kochak Members
edited November 2013 in Sahi Pro
Hi,

I'm trying to call a Java Script file form SAHI script. Need help in doing so. Details below.

Java Script File:

<browser>
function Read_Data()
{
var str='';
//var Grid_Table = document.getElementById("<%= ID NAME %>");
var Grid_Table = document.getElementById("ID NAME");
for(var row=1; row<Grid_Table.rows.length; row++)

{

alert(Grid_Table.rows.length);
for(var col=0; col<Grid_Table.rows[row].cells.length; col++)
{
if(col==0)
if(document.all)
str=str+Grid_Table.rows[row].cells[col].innerText;
else
str=str+Grid_Table.rows[row].cells[col].textContent;
else
if(document.all)
str=str+'--'+Grid_Table.rows[row].cells[col].innerText;
else
str=str+'--'+Grid_Table.rows[row].cells[col].textContent;
}
str=str+'\n';
}
alert(str);
// return false;
}

//Read_Data()
<browser>

SAHI Script:
_include("JAVA SCRIPT FILE NAME")
_call (Read_Data());

Error seen:
When the script tries to execute the function call which is defined in the java script file following error is seen:
Reference Error: Read_Data (which is the function name) not defined.

I have even tried _eval() but no success. Please let me know if anyone has tried this calling functions defined in a Java Script file which is stored at a different location from the script.

Thanks
Sign In or Register to comment.