I'm having problems with the component WebBrowser.
If I load the file normally, the script works. For example:
WebBrowser1.Navigate App.Path & "\Html\samplepage.html" WebBrowser1.SetObjectForScripting Me
Where samplepage.html:
<html> <head> <SCRIPT LANGUAGE="JavaScript"> function button_click() { if (window.external != null) { window.external.ClickFromHTML(); } else { alert("Messagebox from HTML "); } } </SCRIPT> </head> <body> <button onclick="button_click()">Click me</button> </body> </html>
(as in the example available for the component)
But if I use the innerHTML property of the component, the script does not work.
For example:
Dim HTML As String HTML = "<html>" HTML = HTML & "<head>" HTML = HTML & "<SCRIPT LANGUAGE=" & Chr(34) & "JavaScript" & Chr(34) & ">" HTML = HTML & "Function button_click()" HTML = HTML & "{" HTML = HTML & " if (window.external != null)" HTML = HTML & " {" HTML = HTML & " window.external.ClickFromHTML();" HTML = HTML & " }" HTML = HTML & " Else" HTML = HTML & " {" HTML = HTML & " alert(" & Chr(34) & "Messagebox from HTML " & Chr(34) & ");" HTML = HTML & " }" HTML = HTML & "}" HTML = HTML & "</SCRIPT>" HTML = HTML & "</head>" HTML = HTML & "<body>" HTML = HTML & "<button onclick=" & Chr(34) & "button_click()" & Chr(34) & ">Click me</button>" HTML = HTML & "</body>" HTML = HTML & "</html>" WebBrowser1.SetObjectForScripting Me WebBrowser1.InnerHTML = HTML
When I click the button, the following error occurs:
Apparently, the property InnerHTML do not add the tag <Script Language...></Script> How to fix this?
|