views:

341

answers:

2

Possible Duplicate:
How do I get the current location of an iframe?

Hi,

How can I get the URL of the page inside my iFrame.

For exampple, I have a ifarme in my page:

<IFRAME name="Google" id="Google" style="position:absolute;left:0px;top:100px;width:500px;height:500px;z-index:1" src="http://www.google.com/" frameborder="1"></IFRAME>

If the page changes inside the iframe, like if http://www.google.com changes then it should give the appropiate Url.

I tried using document.getElementById("Google").contentWindow, but it gives "Access Denied" error. Any idea how that can be done?

Thanks in advance. Regards, Bhaskardeep Khaund

A: 

Duplicate of: http://stackoverflow.com/questions/44359/how-do-i-get-the-current-location-of-an-iframe And here you have several tutorial how to work with iframe.

Artem Barger
A: 

I think getElementById is not the right thing to use here. Check if this is useful:

var foo=document.getElementsByTagName("iframe");
alert(foo[0].src);
fmartin
I did that, but this is not working for any third party URL. I have read in some posts, that this is not possible. So, my question is can this be acheived using any other way, say like using DIV or something.
Bhaskar