在线等VB BHO判断网页完全加载
正常在WebBrowser1_DocumentComplete判断如下
Private Sub WebBrowser1_DocumentComplete(ByVal pDisp As Object, URL As Variant)
If WebBrowser1.LocationURL = "http://www.youku.com" Then
If pDisp Is WebBrowser1.Object Then MsgBox "页面加载完成"
End If
End Sub
如果直接在WebBrowser1_DocumentComplete事件中写msgbox "页面加载完成" 就会出现多次msgbox
网上找原因说 某些网站都是多个框架每个框架下载完成都回触发DocumentComplete事件
但是我在VB 写的BHO中用却没有.object 请问BHO中如何判断啊?
付代码如下:
引用了 Microsoft Internet Controls
Option Explicit
Implements IObjectWithSiteTLB.IObjectWithSite
Dim WithEvents IE As InternetExplorer
Dim M_Site As IUnknownVB
Private Sub IE_DocumentComplete(ByVal pDisp As Object, URL As Variant)
If IE.LocationURL = "http://www.youku.com" Then
If pDisp Is IE.Object Then MsgBox "页面加载完成" '没有object请高手解决
End If
Private Sub IObjectWithSite_GetSite(ByVal Priid As IObjectWithSiteTLB.GUIDPtr, PPVobj As IObjectWithSiteTLB.VOIDPtr)
M_Site.QueryInterface Priid, PPVobj
End Sub
Private Sub IObjectWithSite_SetSite(ByVal pSite As IObjectWithSiteTLB.IUnknownVB)
Set M_Site = pSite
Set IE = pSite
End Sub
谢谢啊
[解决办法]
If CStr(IE.ReadyState) = 4 Then MsgBox "页面加载完成"