tags:

views:

282

answers:

1

How can I detect when the iframe content has changed and do something upon that change pseudo code below

 $('#waframe').contents().change(function(){
   //do stuff
  });
A: 

Well, Firefox seems to generate a "load" event on an <iframe> element in the context of the containing page. The "load" fires when the "src" is changed; not sure whether it fires when the iframe changes itself.

edit: yes it does seem to fire when the page reloads "internally"

Thus you might try:

$('iframe#yourId').load(function() {
  alert("the iframe has been loaded");
});

I can't try IE at the moment.

Pointy
this doesn't seem to fire in safari or opera I haven't checked ie or chrome yet
mcgrailm
Hmm. Well the Microsoft documentation is not clear on the topic. To test it out, all I did was have a little page with an iframe, and I pointed the iframe to a random domain of mine. In the test page, I just set up a jQuery event listener for "load" on the iframe element.
Pointy
it does work in ff and thats cool but i'm gonna need something that works all the way around the board or a least most of the way
mcgrailm