【IE8是不是允许网页脚本访问计算机关键位置】用WebBrowser打开淘宝宝贝页面,键鼠锁死,电脑死机
【IE8是否允许网页脚本访问计算机关键位置】用WebBrowser打开淘宝宝贝页面,键鼠锁死,电脑死机
运行程序,在Text1中填入:http://item.taobao.com/item.htm?id=12772069714&
点击浏览即死机
Form1.frm
运行程序,在Text1中填入:http://item.taobao.com/item.htm?id=12772069714&
点击浏览即死机
Form1.frm
Option Explicit
Private Declare Function URLDownloadToFile Lib "urlmon" Alias "URLDownloadToFileA" (ByVal pCaller As Long, ByVal szURL As String, ByVal szFileName As String, ByVal dwReserved As Long, ByVal lpfnCB As Long) As Long
Private Declare Sub Sleep Lib "kernel32" (ByVal dwmilliseconds As Long)
Private Sub Command1_Click()
Form1.Caption = "正在打开宝贝信息页面..."
WebBrowser1.Silent = True
WebBrowser1.Navigate Text1.Text
Do Until WebBrowser1.ReadyState = READYSTATE_COMPLETE
DoEvents
Loop
WebBrowser1.SetFocus
Dim i As Long
For i = 1 To 700
SendKeys "{PGDN}"
Next i
Do While WebBrowser1.Busy = True
DoEvents
Loop
Form1.Caption = "开始获取宝贝信息..."
WBDocBodyInnerHtml = WebBrowser1.Document.body.innerHtml
WBDocBodyInnerHtml = Replace(WBDocBodyInnerHtml, """", "")
Call GetBaoBeiInfo
End Sub
Private Sub Command2_Click()
Open "c:\temp001.txt" For Output As #1
Print #1, WebBrowser1.Document.body.innerHtml
Close #1
End Sub
Private Sub WebBrowser1_NavigateComplete2(ByVal pDisp As Object, URL As Variant)
pDisp.Document.parentWindow.execScript "window.alert=null; "
pDisp.Document.parentWindow.execScript "window.confirm=null; "
pDisp.Document.parentWindow.execScript "window.showModalDialog=null; "
pDisp.Document.parentWindow.execScript "window.open=null; "
End Sub
Private Function GetBaoBeiString(strFront As String, strBack As String, LeftToRight As Boolean, Optional ByRef SearchStartPos As Long = 1) As String
Dim StartPos As Long, EndPos As Long, Length As Long
If LeftToRight = True Then
StartPos = InStr(SearchStartPos, WBDocBodyInnerHtml, strFront)
If StartPos = 0 Then
Exit Function
End If
StartPos = StartPos + Len(strFront)
Length = InStr(StartPos, WBDocBodyInnerHtml, strBack) - StartPos
Else
EndPos = InStr(SearchStartPos, WBDocBodyInnerHtml, strBack)
If EndPos = 0 Then
Exit Function
End If
StartPos = InStrRev(WBDocBodyInnerHtml, strFront, EndPos) + Len(strFront)
Length = EndPos - StartPos
End If
GetBaoBeiString = Mid(WBDocBodyInnerHtml, StartPos, Length)