How do I Execute Javascript Function in webpage from external VBScript
Please help im scratching my head here and what I want to do might not even be possible.
Here are the list of items in my project:
[1] - DHTML webpage
[2] - Locally running VBScript
[3] - Locally running applica开发者_如何学运维tion containing source data
Requirement : [2] needs to look at [3], retreive data and post the data to [1].
In [1] I already have a javascript function called InsNewRow(Col1,Col2) which populates a Dynamic table with static data without any issues (this is currently trigged from a Dummy Button OnClick method within [1].)
What I need to do is call the InsNewRow(Col1,Col2) javascript function from [2] and populate the parameters with data sourced from [3] thus dynamically updating the table in [1] with data from [3]
Use VBScript to get the data, then pass it to JavaScript using global variables. JavaScript has access to the VBScript global scope, so it can call the function itself with the dynamic data, which saves time compared to rewriting the function in VBScript or troubleshooting calling the JavaScript function from VBScript:
<!doctype html>
<html>
<head>
<meta charset="UTF-8">
<title>Example document</title>
</head>
<body>
<p>Example paragraph</p>
<script type="text/vbscript">
Dim jscol1
Dim jscol2
function InsNewRow(col1,col2)
jscol1 = col1
jscol2 = col2
InsNewRow = true
end function
call InsNewRow(1,2)
</script>
<script type="text/javascript">
function InsNewRow(col1,col2)
{
alert([col1,col2]);
}
InsNewRow(jscol1,jscol2);
</script>
</body>
</html>
精彩评论