Occurs when script running inside of the window encounters a run-time error.
Assembly: System.Windows.Forms (in System.Windows.Forms.dll)
HTML pages can contain script code, usually written in JScript or VBScript, that executes when a page is loaded. occurs whenever a script encounters a run-time error. Because script code is late-bound, which means that calls against the object are not resolved until run-time, errors can include everything from referencing a null object to calling an undefined property or method.
For more information about the difference between canceling event bubbling and canceling the default action on an event, see About the DHTML Object Model.
The following code example traps the error that results when a script on an HTML page attempts to access an object that is not defined in the document. The page must be fully loaded before the event handler is attached, otherwise the example will not work.
Dim WithEvents ScriptWindow As HtmlWindow Private Sub SuppressScriptErrors() If (WebBrowser1.Document IsNot Nothing) Then ScriptWindow = WebBrowser1.Document.Window End If End Sub Private Sub ScriptWindow_Error(ByVal sender As Object, ByVal e As HtmlElementErrorEventArgs) Handles ScriptWindow.Error MessageBox.Show("Suppressed error!") e.Handled = True End Sub
Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows XP SP2 x64 Edition, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2
The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.