I have an HTML page that uses javascript / jquery to reload the contents of an iframe:
$('#my-frame').attr("src","someotherpageinthesamedomain");
What I’d like to happen is to be able to manipulate the HTML of the iframe after it reloads. I tried this:
$("#my-frame").load(dostuff());
But that does not wait for the reload — I’m guessing because the iframe is already loaded with its original content.
You have to pass the function, not call it:
Putting parenthesis after a function’s name calls the function immediately and, in your case, will pass the return value to
.load()(which is ok, if the return value is a function, but I guess it is not).And yes, you might have to set the handler before you change the
srcattribute.