CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 4 of 4
  1. #1
    Join Date
    Jun 2009
    Posts
    2

    [Help]VB6 + Webbrowser + Iframes + Different Domains]

    1 - The Situation:
    I'm Using "Visual Basic 6"
    I'm Using "Webbrowser Control"
    I'm Using "Microsoft HTML Object Library"

    ====================================================

    2 - What I Want:
    *Acees objects (buttons, links, etc) on a IFRAME
    *Get all links for example, click in links, etc...

    This is easy... but...

    ===================================================

    3- THE PROBLEM:
    The page A is in www.abc.com
    The page B is in www.xyz.com
    The Page A contains one iframe to page B
    I Can't acess elements in Iframes with diferrent domains using normal methods.

    ====================================================

    4 - Example:

    PAGE A.html (www.abc.com/PageA.html) ==>
    <html>
    <body>
    THIS IS THE PAGE A!<Br>
    PAGE A contains one Iframe to PAGE B!<br>
    <Iframe id="PageB" name="PageB" src="http://www.xyz.com/PageB.html">
    </body>
    </html>

    ====================================================

    For example, if a try to get links of page B (iframe) pufff...
    "{"Access Denied. (Exception from HRESULT: 0x80070005 (E_ACCESSDENIED))"}"

    ====================================================

    5 - The phrase for the more experienced are:

    Nothing is impossible! you know!
    How can I then perform this procedure?

    Thanks

    ====================================================

  2. #2
    Join Date
    Jan 2006
    Location
    Fox Lake, IL
    Posts
    15,007

    Re: [Help]VB6 + Webbrowser + Iframes + Different Domains]

    Just figure out what Point A is sending over to Point B, and try to do the same thing. They probably have cross-domain trust built, so sending from your IP address won't work
    David

    CodeGuru Article: Bound Controls are Evil-VB6
    2013 Samples: MS CODE Samples

    CodeGuru Reviewer
    2006 Dell CSP
    2006, 2007 & 2008 MVP Visual Basic
    If your question has been answered satisfactorily, and it has been helpful, then, please, Rate this Post!

  3. #3
    Join Date
    Jun 2009
    Posts
    2

    Re: [Help]VB6 + Webbrowser + Iframes + Different Domains]

    It is not that simple = P


    anyone have any information?

  4. #4
    Join Date
    Jan 2006
    Location
    Fox Lake, IL
    Posts
    15,007

    Re: [Help]VB6 + Webbrowser + Iframes + Different Domains]

    You're right. Probably impossible.
    I Can't acess elements in Iframes with diferrent domains using normal methods.
    that'd be my last post regarding CROSS-DOMAIN TRUST

    This should help with the frame issue to some degree:

    Code:
    Option Explicit
    ' Use component M$ HTML Object Library
    
    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
    
    Dim colDocuments As Collection
    
    Private Function GetFile(URL As String) As String
    'Purpose: returns file title of a URL or local path
    If Mid$(URL, 2, 2) = ":\" Then
        'Local Path
        GetFile = Right$(URL, Len(URL) - InStrRev(URL, "\"))
    ElseIf InStrRev(URL, "/") > InStrRev(URL, ".") Then
        'Complete URL
        GetFile = Left$(Replace(URL, "http://", ""), Len(Replace(URL, "http://", "")) - 1)
    Else
        'File
        GetFile = Right$(URL, Len(URL) - InStrRev(URL, "/"))
    End If
    End Function
    
    Private Sub Form_Load()
    Dim objDoc1 As HTMLDocument
    Dim objDoc2 As HTMLDocument
    Dim i As Integer
    Dim t As Integer
    Set objDoc1 = New HTMLDocument
    'Create document element from url
    Set objDoc2 = objDoc1.createDocumentFromUrl("http://www.hamcams.com", vbNullString)
    
    'Wait till document has loaded
    Do While objDoc2.readyState <> "interactive"
        DoEvents
    Loop
    GetFrames
    'Loop through images
    For t = 1 To colDocuments.Count
      For i = 0 To objDoc2.images.length - 1
          'download images and save them in app.path
          URLDownloadToFile 0, objDoc2.images.Item(i).href, App.Path & "\Images\" & GetFile(objDoc2.images.Item(i).href), 0, 0
      Next i
    Next t
    Set objDoc1 = Nothing
    Set objDoc2 = Nothing
    Beep
    End Sub
    
    
    Private Sub GetFrames()
    'Purpose: searches all frames in the document(s) and adds them to colDocuments
    On Error Resume Next
    Dim i As Integer, j As Integer
    j = 1
    
    Set colDocuments = New Collection
    colDocuments.Add WebBrowser1.document
    
    Do While j < colDocuments.Count + 1
        For i = 0 To colDocuments.Item(j).frames.length - 1
            colDocuments.Add colDocuments.Item(j).frames.Item(i).document
        Next i
        j = j + 1
    Loop
    End Sub
    Last edited by dglienna; June 17th, 2009 at 01:50 AM.
    David

    CodeGuru Article: Bound Controls are Evil-VB6
    2013 Samples: MS CODE Samples

    CodeGuru Reviewer
    2006 Dell CSP
    2006, 2007 & 2008 MVP Visual Basic
    If your question has been answered satisfactorily, and it has been helpful, then, please, Rate this Post!

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured