Codejock Forums Homepage
Forum Home Forum Home > Codejock Products > Visual C++ MFC > Controls
  New Posts New Posts RSS Feed - WebBrowser1.InnerHTML
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

WebBrowser1.InnerHTML

 Post Reply Post Reply
Author
Message
CDias View Drop Down
Newbie
Newbie
Avatar

Joined: 06 January 2012
Location: Brasil
Status: Offline
Points: 2
Post Options Post Options   Thanks (0) Thanks(0)   Quote CDias Quote  Post ReplyReply Direct Link To This Post Topic: WebBrowser1.InnerHTML
    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?
Back to Top
 Post Reply Post Reply
  Share Topic   

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 12.04
Copyright ©2001-2021 Web Wiz Ltd.

This page was generated in 0.109 seconds.