Using Jquery, how can I get the URL of an iframe after redirection has occurred to a URL in the same domain?
Asked
Active
Viewed 1.7k times
6
-
1What kind of redirection? Where is the jQuery instance running? – Pekka Sep 12 '10 at 21:05
-
I think it's a redirect with a location header. What do you mean with your second question? I'm not running this script on the same site. I just need to find out the URL which it's redirecting to programatically. – Matthew H Sep 12 '10 at 21:07
1 Answers
8
The suggestion from sunn0 should work with this slight amendment.
$("#iframeid").load(function(){
alert(this.contentWindow.location);
});

Fenton
- 241,084
- 71
- 387
- 401
-
2@confiq are you loading a page on the same domain in the iframe? You can only inspect the location on the same domain. – Fenton Nov 05 '13 at 12:56
-
1Yeah, I've figure out that I can't access `.location` property if it's not same domain/port. – confiq Nov 05 '13 at 15:49