比如说,我有一个Html网页源码如下:<html>
<frameset rows="20%,20%,20%,20%,20%">
<frame src="http://www.aaa.com">
<frame src="http://www.bbb.com">
<frame src="http://www.cccc.com">
<frame src="http://www.dddd.com">
<frame src="http://www.eeeee.com">
</frameset>
</html>这个网页有五个框架,分别引入了各自的网页.我想获取其中某个框架的源码,怎么操作呢?我可以获取到框架的数量:webbrowser1.document.frames.length 这个是获取其数量如何取其中一个框架中的网页源码呢?懂的高手们帮帮小弟吧

解决方案 »

  1.   

    难道这个样不行?webbrowser1.document.frames(0)
      

  2.   

    试试 
    Private Sub WebBrowser1_DocumentComplete(ByVal pDisp As Object, URL As Variant)
        Me.Print test(WebBrowser1)
    End SubPrivate Function test(wb1 As WebBrowser) As String
        Dim vDoc As Object, vTag As Object
        Dim i%, strTagName$, strTagName2$, strTagType$, strTagValue$, strLine$
        
        Set vDoc = wb1.Document
        For i = 0 To vDoc.All.Length - 1 '检测所有标签
            strTagName = vDoc.All(i).tagName
            strTagName2 = UCase(strTagName)
            If strTagName2 = "INPUT" Or strTagName2 = "TEXTAREA" Or strTagName2 = "SELECT" Then
                strLine = strLine & i + 1 & "*" & strTagName & "*" & _
                            "Name:" & vDoc.All(i).Name & "*" & _
                            "Id:" & vDoc.All(i).Id & "*" & _
                            "Type:" & vDoc.All(i).Type & "*" & _
                            "Value:" & vDoc.All(i).Value & "*" & vbCrLf
            ElseIf strTagName2 = "A" Then
            strLine = strLine & i + 1 & "*" & strTagName & "*" & _
                            "href:" & vDoc.All(i).href & "*" & _
                            "OnClick:" & vDoc.All(i).OnClick & "*" & vbCrLf
            Else
                strLine = strLine & i + 1 & "*" & strTagName & vbCrLf
            End If
        Next i
        test = strLine
    End Function
      

  3.   

    是的webbrowser1.document.frames(0)  你这样是获取不到你想的某个框架对象的.我试过好多方法,都不能获取想要的框架的文档对象.
      

  4.   


    webbrowser1.Document.getElementById("mainFrame").contentWindow
      

  5.   

    webbrowser1.Document.getElementById("mainFrame").contentWindowcontentWindow能帮助你取得网页框架对象  
      

  6.   

    webbrowser1.Document.getElementById("mainFrame").contentWindow.document.body.innerhtml
      

  7.   

    对于楼主这样的问题,我专门研究过,参考:
    http://topic.csdn.net/u/20100826/21/57113d41-6a6f-4b97-b20d-70bf26f55b7e.html
    http://tieba.baidu.com/p/873865493