6

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

Matthew H
  • 5,621
  • 7
  • 46
  • 81
  • 1
    What 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 Answers1

8

The suggestion from sunn0 should work with this slight amendment.

 $("#iframeid").load(function(){
    alert(this.contentWindow.location);
 });
Fenton
  • 224,347
  • 65
  • 373
  • 385
  • 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
  • 1
    Yeah, 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