Martin Ongtangco
Martin Ongtangco

Reputation: 23515

constantly check iframe if url has been changed from inside via Jquery

Is this possible?

Upvotes: 2

Views: 1049

Answers (4)

ehmad
ehmad

Reputation: 2623

yh this works:

1_

 <iframe src ="page.html" name="fraFrame" id="fraFrame" onLoad="alert('url changed!!!');"> 
    <p>Your browser does not support iframes :P</p>
 </iframe>

2_ using DOM reference or jquery thing:

$("#fraFrame").load(function (){
    // do something once the iframe is loaded
});

Upvotes: 2

Josh Stodola
Josh Stodola

Reputation: 82483

Assuming you have just one iframe...

$("iframe").load(function() {
  alert("Changed!");
  alert(frames[0].document.body.innerHTML);
});

Upvotes: 3

IgalSt
IgalSt

Reputation: 1984

I'm not sure if this will work, but I would try to do it: You can try and bind a "load" event to the iframe. Once the URL has changed the iframe should fire the load event as the page has been reloaded.

Upvotes: 1

Darin Dimitrov
Darin Dimitrov

Reputation: 1038800

You may take a look at the window.setInterval function. Also instead of constantly polling can't you be notified by the javascript code that changes the src property for this change?

Upvotes: 1

Related Questions