none
[vb6][WebBrowser]如何為 WebBrowser 控制項抑制 run-time script errors RRS feed

  • 一般討論

  • '來源:http://support.microsoft.com/kb/279535/zh-tw

    'http://kbalertz.com/279535/Suppress-Script-Errors-WebBrowser-Control-Visual-Basic-Application.aspx


    Const e_sURL1 = "http://gogobox.com.tw/"

    Dim WithEvents objDoc As MSHTML.HTMLDocument
    Dim WithEvents objWind As MSHTML.HTMLWindow2
    Dim objEvent As CEventObj

    Private Sub Form_Load()
    WebBrowser1.Navigate e_sURL1
    End Sub

    Private Sub Form_Resize()
        With WebBrowser1
            .Top = Me.ScaleTop
            .Left = Me.ScaleLeft
            .Height = Me.ScaleHeight
            .Width = Me.ScaleWidth
        End With
    End Sub

    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

    Private Sub WebBrowser1_NavigateComplete2(ByVal pDisp As Object, URL As Variant)
        Set objDoc = WebBrowser1.Document
        Set objWind = objDoc.parentWindow
    End Sub

     

    問題是:

    沒有WebBrowser1_NavigateComplete 事件只有WebBrowser1_NavigateComplete2 事件

     

    重點是雖然 當WebBrowser1_NavigateComplete2 時  

    Set objDoc = WebBrowser1.Document

    Set objWind = objDoc.parentWindow

    有執行可是當 Script RunTime error 時卻沒有呼叫   objWind_onerror

    WHY??

     

    類似問題

    http://bytes.com/forum/thread224188.html

     

     

     

     

    2008年7月20日 下午 09:15