Paste below code in your VB project. Put a Webbrowser control and two Command buttons on the Form. Run the project and then click button 1 to load the HTM page then click button 2 to see the results. Clicking the button on the Web doc won't do anything to get results; you need to click button2 on your VB Form.
Code:
Private Sub Command1_Click()
WebBrowser1.Navigate App.Path & "\JavaScript.html"
End Sub
Private Sub Command2_Click()
Results = WebBrowser1.Document.All("a4").Value
MsgBox Results
End Sub
Private Sub WebBrowser1_DocumentComplete(ByVal pDisp As Object, URL As Variant)
If URL = App.Path & "\JavaScript.html" Then
WebBrowser1.Document.All("a1").Value = "JMSRICKLAND WAS HERE"
WebBrowser1.Document.All("a2").Value = "WAS"
WebBrowser1.Document.All("a3").Value = "IS"
WebBrowser1.Document.All("myButton").Click
End If
End Sub
Here is the HTML document
Code:
<HTML>
<BODY>
<CENTER>
<FORM NAME="myForm">
<INPUT TYPE=Text NAME=a1 VALUE="">
<INPUT TYPE=Text NAME=a2 VALUE="">
<INPUT TYPE=Text NAME=a3 VALUE="">
<INPUT TYPE=hidden NAME=a4 VALUE="">
<INPUT TYPE="button" NAME="myButton" VALUE="Click Me" onClick="Replace(form.a1.value, form.a2.value, form.a3.value)">
</CENTER>
<SCRIPT type="text/javascript">
{
function Replace(Arg1, Arg2, Arg3)
{
myForm.a4.value = Arg1.replace(Arg2, Arg3);
}
</SCRIPT>
</FORM>
</BODY>
</HTML>