To suppress the default Internet Explorer error message for the window onerror event
To suppress the default Internet Explorer error message for the window
onerror event, you can set the
returnValue property of the event object to True.
To set the
returnValue property to True, perform the following steps:
- Create a new Visual Basic standard EXE project. Form1 is created by default.
- Add a WebBrowser control to Form1.
- Add a Project Reference to the Microsoft HTML Object Library (Mshtml.tlb).
- In the declarations section of Form1, add the following code:
Dim WithEvents objDoc As MSHTML.HTMLDocumentDim WithEvents objWind As MSHTML.HTMLWindow2Dim objEvent As CEventObj
- In the WebBrowser1_NavigateComplete event, add the following code:
Private Sub WebBrowser1_NavigateComplete() Set objDoc = WebBrowser1.Document Set objWind = objDoc.parentWindow End Sub
- Add an event handler for the window onerror event as follows:
Private Sub objWind_onerror(ByVal description As String, ByVal URL As String, ByVal line As Long) Set objEvent = objWind.event objEvent.returnValue = True MsgBox (description) End Sub
本站仅提供存储服务,所有内容均由用户发布,如发现有害或侵权内容,请
点击举报。