如果我们枚举Web Browser的Document对象中所有的元素,只能的页面框架的元素,请问怎样才能获得框架 src所指向页面的元素。

解决方案 »

  1.   

    The capability of scripting across domain is affected by builtin security. Under "IE security settings" - "Miscellaneous", there are the options "Access data sources across domains" and "Navigate sub-frames across different domains".Dim pFramesCol As IHTMLFramesCollection2
    !   Dim pDisp As Object
        Dim IWindow2 As IHTMLWindow2
        Dim i As Integer
    !   Dim varIndex As Variant
        Dim frameDoc As IHTMLDocument2
       
       Set pFramesCol = doc.frames
       
       If Not pFramesCol Is Nothing Then
       
          For i = 0 To pFramesCol.length - 1
         
             varIndex = i
             
             Set pDisp = pFramesCol.Item(varIndex)
             
    !        ' pDisp.QueryInterface IHTMLWindow2, IWindow2!         Set IWindow2 = pDisp
             
             If Not IWindow2 Is Nothing Then
             
                If Not IWindow2.Document Is Nothing Then            <== Possible error may arise: Access Denied
             
                   Set frameDoc = IWindow2.Document
               
                End If
             End If
          Next i      
       End If
      

  2.   

    搞定了。
    webrowser.document.frames.item(index).all(i)