如我现在打开
Private Sub Command2_Click()WebBrowser1.Navigate "http://www.baidu.com/"?
a=3+2
mogbox a
End Sub
如果某个网页有很多图片,加载完成要很慢,判断整个网页是否加载完成,才弹出mogbox,该怎么写,现在是不管加载完成没完成他都直接弹出

解决方案 »

  1.   

    While WebBrowser1.Busy
        DoEvents
    Wend
    WebBrowser1_DownloadComplete()
      

  2.   

    Private Sub WebBrowser1_DocumentComplete(ByVal pDisp As Object, Url As Variant)  
            
        If (pDisp Is WebBrowser1.Object) Then
            a=3+2
            mogbox a
        End If  End Sub
      

  3.   

    Do
    DoEvents
    If WebBrowser1.Busy = True Then
    Else    Dim htmhref As New HTMLAnchorElement
        Dim htmldoc As New HTMLDocument
        Dim htmlEle As New HTMLDTElement
        Dim htmlEles As IHTMLElementCollection
        Dim nlen As Long
        Set htmldoc = WebBrowser1.Document
        Set htmlEles = htmldoc.All
        nlen = htmlEles.length
        Dim i As Long
        Dim j As Long
        j = 0
        For i = 0 To nlen - 1
            Set htmlEle = htmlEles.Item(i)
            If (htmlEle.tagName = "A") Then
                Set htmhref = htmlEle
                aaa = "http://map.baidu.com"
                 If InStr(1, htmhref.href, aaa) <> 0 Then
                    Ret = SendMessageFind(List1.hwnd, LB_FINDSTRING, 0, (htmhref.href))
                    If Ret = LB_ERR Then
                        List1.AddItem htmhref.href
                        If List1.ListCount >= 1000 Then Exit Do
                        Me.Caption = List1.ListCount
                    End If
                End If
            End If
        Next i
    End If
    Loop
      

  4.   

    Private Sub WebBrowser1_DocumentComplete(ByVal pDisp As Object, URL As Variant)
    If WebBrowser1.LocationURL = "http://www.qq.com" Then
      If pDisp Is WebBrowser1.Object Then MsgBox "页面加载完成"
    End If
    End Sub
      

  5.   

    可以用timer控件配合判断WebBrowser1的busy属性值来确定是否加载完成。