I have an iframe which I'm loading dynamically based on a parameter in the URL coming in. There are also certain actions on the page a user can take that change the src of the iframe to display another page. Is there a JavaScript function which I can bind to that will tell me when the src changes?
For instance the user browses to my page and I dynamically load "www.mysite.com/page1" Now the user does something and page1 is replaced by "www.mysite.com/page2".
I'd like to detect the change and act on it. Something like: document.getElementById("myIFrame").onSrcChange(doFunction());
And before anyone asks, no I can't detect the user does something part, I have to rely on the iFrame change as what to try and detect.
If it makes any difference, this must work in IE. Thanks!
You can use "onload" event on iframe tag to detect iframe src change, when src is changed new page is loaded in iframe and "onload" event is triggered.
you can also use on "onhashchange" event to detect hash changes as well.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With