您好我是Visual Basic 6的新手, 我的应用程序有一个显示广告的部分。点击广告后,“电源”按钮即被激活。
我尝试检测点击我的广告内部的广告,其中包含ID“anuncio1”。
到目前为止,我只是设法检测到您何时单击WebBrowser区域,但未检测到我何时单击链接。
然后我让我的代码:
Option Explicit
'Reference to HTML DOM
Dim WithEvents HTMLDOC As HTMLDocument
Private Const READYSTATE_COMPLETE As Long = 4
'Load the website directly to the ad hiding Scrollbars and focusing anchor #anuncio1
Private Sub Form_Load()
WebBrowser1.Navigate "www.traductoramixer.es#anuncio1"
Do While WebBrowser1.Busy: DoEvents: Loop
Do While WebBrowser1.ReadyState <> READYSTATE_COMPLETE: DoEvents: Loop
WebBrowser1.Document.parentWindow.scrollBy 25, 0
WebBrowser1.Document.body.Scroll = "no"
WebBrowser1.Document.body.Style.overflow = "hidden"
End Sub
'Deteck click in WebBrowser1 zone
Private Function HTMLDOC_onclick() As Boolean
Command1.Enabled = True
End Function
Private Sub WebBrowser1_DocumentComplete(ByVal pDisp As Object, URL As Variant)
If Not WebBrowser1.Document Is Nothing Then
Set HTMLDOC = WebBrowser1.Document
End If
End Sub
答案 0 :(得分:0)
1)创建一个具有间隔100
的定时器2)并经常检查WebBrowser1.LocationName字符串值
如果其值不等于客户点击的网址,请确保您的客户点击了错误的链接