HtmlElementErrorEventArgs.Handled 屬性

定義

取得或設定值,指出裝載文件的應用程式是否已處理這個錯誤。

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 設定為 。

適用於