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
2010-09-12 21:08:26
This just returns the original URL, not the URL after redirection.
Matt H
2010-09-12 21:12:44
Yup, I don't think this will work.
Pekka
2010-09-12 21:13:10
You are correct. Sorry about that. See http://stackoverflow.com/questions/2429045/iframe-src-change-event-detection
sunn0
2010-09-12 21:19:09
+1
A:
The suggestion from sunn0 should work with this slight amendment.
$("#iframeid").load(function(){
alert(this.contentWindow.location);
});
Sohnee
2010-09-21 10:06:07