HOWTO: Insert Event Handler Into Web Page from WebBrowser AppID: Q185128
|
When you are hosting the WebBrowser control in your applications, you may want to insert an event handler for a script event. This article describes how do that in a Visual Basic application.
There are three important points to note when trying to insert script for event handlers on your Web pages from your Visual Basic application.
Q185140 PRB: Trouble Inserting Non-Displayable HTML into Web Page
Option Explicit
Private Sub Command1_Click()
Dim str As String
' Insert some hidden HTML and the script
str = "<span style='display:none'>h</span><script defer>" & _
"function document.onclick() {alert(1);}</script>"
WebBrowser1.Document.body.insertAdjacentHTML "BeforeEnd", str
End Sub
Private Sub Form_Load()
WebBrowser1.Navigate "http://SomeServer/SomeWebPage.htm"
End Sub
Debug.Print WebBrowser1.Document.body.outerHTML
For more information, see the MSDN Online Web Workshop:
http://msdn.microsoft.com/workshop/
Additional query words: kbDSupport kbdsi
Keywords : kbIE400 kbIE401 kbIE500 AXSDKWebBrowser
Version : WINDOWS:4.0,4.01,5.0
Platform : WINDOWS
Issue type : kbhowto
Last Reviewed: April 28, 1999