Link to home
Start Free TrialLog in
Avatar of alzj
alzj

asked on

Question for AzraSound

Hi,

The following code I got it from you for a couple of years ago:

Dim strHTML As String
Dim i As Integer
strHTML = WebBrowser.Document.documentElement.outerhtml
For i = 0 To WebBrowser.Document.frames.length - 1
    strHTML = strHTML & vbCrLf & WebBrowser.Document.frames.item(i).document.documentElement.outerhtml
Next
'-------

It doesn't work with sites that have iframes, you get an access denied.

 You can try this site:

                www.nordea.se

I have 2 questions:

1) Is it possible to modify the code in order to get the iframes of a site as well?

    if not:

2) Is it possible to modify the code in order to get the HTML code of a site (the frameset and the frames) except code for the iframes?

      Thanks
Avatar of AzraSound
AzraSound
Flag of United States of America image

Hi,
Just saw this question.  Offhand, I can't offer anything, but if I have time later, I will try and play around and see if I can find you a solution.
ASKER CERTIFIED SOLUTION
Avatar of AzraSound
AzraSound
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
You cannot get the html of the document loaded in the iframe, which is what I assume the questioner is asking for.
When using the line..

Text1 = Text1 & o.outerhtml & vbCrLf

..the output is the following:


<IFRAME style="BORDER-RIGHT: medium none; BORDER-TOP: medium none; BORDER-LEFT: medium none; WIDTH: 100%; BORDER-BOTTOM: medium none; HEIGHT: 80px" marginWidth=0 marginHeight=0 src="http://app.nordea.se/titelsidan/iframe.html" frameBorder=0 width="100%" height=80></IFRAME>




and when using the line..

Text1 = Text1 & o.src & vbCrLf

..the output is:

http://app.nordea.se/titelsidan/iframe.html
That is part of the html source of the page containing the iframe.  The question is, how to get the source of the document loaded in the iframe.  In other words, pull the html source from http://app.nordea.se/titelsidan/iframe.html.
Avatar of alzj
alzj

ASKER

Thanks fpr the replys.

It looks like it's difficult to get the HTML code for the iframe with an app. In order to get that I can either navigate to it, or I can find its location on the site, then click on it with the right mouse button och choose "view source". In this case its location is around "Dagens fråga".

Anyway, I will leave the question open for a while, maybe a solution will come up.
Yes, you would have to navigate to it in a separate webbrowser window, for example.  There is no direct way because of the security issue described in the link above.
Avatar of alzj

ASKER

AzraSound:

Your solution "On Error Resume Next" does not work. I navigate to a site that had a couple of frames and iframes and the only thing I could get when I used "On Error Resume Next" was the code for the frameset. Pitty!
Anyway I don't think there is more to say about this. If you ever find a solution, either you or vb_elmar don't hesitate to post it here.

P.S. I will split the points, AzraSound get 75 and vb_elmar gets 50.
>>Your solution "On Error Resume Next" does not work

Were those frames pointing to sites in different domains?  If so, its the same problem.  On Error Resume Next was just to avoid any error messages popping up and allow you to try and pull the source of the next frame.  The only "real" solution would be to investigate the src attribute if each frame, compare it to the current url, and if they are in different domains, navigate to the frame src in a separate [hidden] web window to get its html source.