Get URL of image displayed in IFRAME?

Hi,

I asked this question a while ago and was surprised that nobody had an answer. Ill try my luck again, this time with a slightly rephrased description of the problem. Hopefully somebody can point me in the right direction.

Many webpages position ads in IFRAMEs. Usually they display an image in the IFRAME. Left-clicking on it opens the linked page. Right-clicking allows either to save the image (Save Image as) or to view its properties. In the property window the full address of the image is revealed, for example:

https://img.web.de/_Muster/bookmark/credit.gif

MY QUESTION: IS IT POSSIBLE TO PROGRAMMATICALLY RETRIEVE THE SAME INFORMATION THE ADDRESS OF THE IMAGE?

The source code of the webpage only contains an src to the document linked in the IFRAME but not the address of the image, for example:

<IFRAME src="/iframe.ng/site=freemail&category=login&special=top&adsize=468x60&content=webde" width="640" height="70" scrolling="no" marginwidth="0" marginheight="0" frameborder="0">
</IFRAME>

Accessing the content of the document linked in the IFRAME is not possible because of cross frame security.

Here is an example site: http://freemail.web.de
The second element from the top is an IFRAME, containing five different ads.

I fooled around with this, without much success:

Private Sub setEvent(doc As HTMLDocument)
Dim sElement As IHTMLElement
Dim testforError As String

On Error Resume Next
' MsgBox "setEvent " & doc.location.href

For Each sElement In doc.All
testforError = sElement.tagName
If Err.Number = 0 Then
With sElement
If .tagName = "IMG" Or .tagName = "A" Then .
If sElement.tagName = "FRAME" Then .

'=========================================
'This approach only provides the src to the document linked in the IFRAME
'How to get the address of the image displayed in the IFRAME? Obviously
'Internet Explorer knows how to get it, since it shows it in the property window
If sElement.tagName = "IFRAME" Then
For cnt = 0 To doc.All.length
If doc.All(cnt).sourceIndex = sElement.sourceIndex Then MsgBox doc.All(cnt).src
Next
End If
'=========================================

If Err.Number <> 0 Then
Debug.Print Err.Description
Err.Clear
End If
End With
End If
Next
End Sub

Thanks for your help!
[2796 byte] By [9Mark9] at [2007-11-18 18:21:07]
# 1 Re: Get URL of image displayed in IFRAME?
Originally posted by 9Mark9
MY QUESTION: IS IT POSSIBLE TO PROGRAMMATICALLY RETRIEVE THE SAME INFORMATION THE ADDRESS OF THE IMAGE?

Sure, there are many ways to do that. No need to shout. What language would you prefer to do it in ?

Originally posted by 9Mark9
Accessing the content of the document linked in the IFRAME is not possible because of cross frame security.

I have no truble opening the page

http://freemail.web.de/iframe.ng/site=freemail&category=login&special=top&adsize=468x60&content=webde

Which contains 5 iframes with references to pages that I can also open individually without any problems.

Another solution would be to use a browser that lets you view the properties/code for induvidual frames, I'am not sure if IE does this but Mozilla does, simply rightclick on the frame and select 'This frame' you will get a menu that lets you view all relevant information on that particular frame.

Private Sub setEvent(doc As HTMLDocument)
Dim sElement As IHTMLElement
Dim testforError As String

On Error Resume Next
' MsgBox "setEvent " & doc.location.href

For Each sElement In doc.All
testforError = sElement.tagName
If Err.Number = 0 Then
With sElement
If .tagName = "IMG" Or .tagName = "A" Then .
If sElement.tagName = "FRAME" Then .

'=========================================
'This approach only provides the src to the document linked in the IFRAME
'How to get the address of the image displayed in the IFRAME? Obviously
'Internet Explorer knows how to get it, since it shows it in the property window
If sElement.tagName = "IFRAME" Then
For cnt = 0 To doc.All.length
If doc.All(cnt).sourceIndex = sElement.sourceIndex Then MsgBox doc.All(cnt).src
Next
End If
'=========================================

If Err.Number <> 0 Then
Debug.Print Err.Description
Err.Clear
End If
End With
End If
Next
End Sub

I'am feeling old, I don't even know what language this is, VBScript ?
khp at 2007-11-8 0:19:07 >
# 2 Re: Get URL of image displayed in IFRAME?
Sorry for the delay. In my part of the world (Austria) it was time to get some sleep ...

Im glad to hear that there is more than one way to do this. Im writing this BHO in VB6, therefore that would be my prefered language. I would like to get the image displayed in the IFRAME (any IFRAME). I assume the only way to save it is by knowing its url.

Is it possible to obtain this information without having to leave the main page and navigating to the IFRAME address?

Thanks.
9Mark9 at 2007-11-8 0:20:16 >
# 3 Re: Get URL of image displayed in IFRAME?
Sorry for the delay. In my part of the world (Austria) it was time to get some sleep ...

Im glad to hear that there is more than one way to do this. Im writing this BHO in VB6, therefore that would be my prefered language. I would likte to get the image displayed in the IFRAME (any IFRAME). I assume the only way to save it is by knowing its url.

Is it possible to obtain this information without having to leave the main page and navigating to the IFRAME address?

Thanks.
9Mark9 at 2007-11-8 0:21:15 >