views:

109

answers:

2

Using Jquery, how can I get the URL of an iframe after redirection has occurred to a URL in the same domain?

A: 
$("#iframeid").attr("src");

Edit: Assuming the redirect occurs in the iframe and not on your main page

And if you don't know if or when the redirect will happen use the onload event:

 $("#iframeid").load(function(){
    $(this).attr("src");
 });
sunn0
This just returns the original URL, not the URL after redirection.
Matt H
Yup, I don't think this will work.
Pekka
You are correct. Sorry about that. See http://stackoverflow.com/questions/2429045/iframe-src-change-event-detection
sunn0
+1  A: 

The suggestion from sunn0 should work with this slight amendment.

 $("#iframeid").load(function(){
    alert(this.contentWindow.location);
 });
Sohnee