Print Page | Close Window

WebBrowser1.InnerHTML

Printed From: Codejock Forums
Category: Codejock Products
Forum Name: Controls
Forum Description: Topics Related to Codejock Controls
URL: http://forum.codejock.com/forum_posts.asp?TID=19389
Printed Date: 04 December 2024 at 1:59pm
Software Version: Web Wiz Forums 12.04 - http://www.webwizforums.com


Topic: WebBrowser1.InnerHTML
Posted By: CDias
Subject: WebBrowser1.InnerHTML
Date Posted: 06 January 2012 at 7:42pm
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?



Print Page | Close Window

Forum Software by Web Wiz Forums® version 12.04 - http://www.webwizforums.com
Copyright ©2001-2021 Web Wiz Ltd. - https://www.webwiz.net