vb的webbrowser获取一个用js做的网页,高分求帮忙!
我想用vb的webbrowser获取一个用js做的网页,这个网页有三层iframe,然后我想webbrowser能够读到最后一层iframe,而这些iframe的src都是赋值的
我主要目的是想获取到最后一层的某一个input,然后给它的value赋值
iframe的格式:<iframe name="funcPlaceFrame" width="100%" height="100%" id="funcPlaceFrame" src="" frameBorder="0" scrolling="auto">
小弟不才,查了几天资料还是不能解决这个问题,希望高人帮忙!!!在线等帮忙
[解决办法]
给个跨框架点击的函数例子,仅供你参考
Function ClickTheId(TheDocument As HTMLDocument, TheId As String) As Boolean Dim ElWithId As Object, oFrame As IHTMLWindow2, oDoc As HTMLDocument, i As Long, bClicked As Boolean Set ElWithId = TheDocument.getElementById(TheId) If Not ElWithId Is Nothing Then On Error Resume Next ElWithId.focus On Error GoTo 0 ElWithId.Click Set ElWithId = Nothing ClickTheId = True ElseIf TheDocument.frames.length > 0 Then For i = 0 To TheDocument.frames.length - 1 Set oFrame = TheDocument.frames(i) On Error Resume Next Set oDoc = oFrame.Document If Err.Number = 70 Then frmDenied = frmDenied + 1 MsgBox "Error # " & Err.Number & ", " & Err.Description & vbCrLf & _ "Source: " & Err.Source, , "Error" Else bClicked = ClickTheId(oDoc, TheId) If bClicked Then ClickTheId = True: Exit Function End If Next i ClickTheId = False Else ClickTheId = False End IfEnd Function
[解决办法]
应该要用上
HTMLDocument的parentWindow
[解决办法]
要用上getElementById