HtmlElementErrorEventArgs.Handled 屬性
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
讀取或設定該錯誤是否已被文件主機應用程式處理。
public:
property bool Handled { bool get(); void set(bool value); };
public bool Handled { get; set; }
member this.Handled : bool with get, set
Public Property Handled As Boolean
屬性值
true如果事件已經處理完畢;否則,。 false 預設值為 false。
範例
以下程式碼範例示範如何抑制腳本錯誤並顯示你自己的自訂對話框。 此程式碼範例要求您的應用程式必須承載一個 WebBrowser 名為 webBrowser1的控制項。
private void SuppressScriptErrors()
{
if (webBrowser1.Document != null)
{
webBrowser1.Document.Window.Error += new HtmlElementErrorEventHandler(scriptWindow_Error);
}
}
private void scriptWindow_Error(object sender, HtmlElementErrorEventArgs e)
{
MessageBox.Show("Suppressed error!");
e.Handled = true;
}
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
備註
若你想向使用者顯示自訂錯誤訊息,或完全抑制錯誤,請將此屬性設定 true 為