Need To Clearinterval In Iframe From Parent And It's Not Working
I'm using setInterval inside an iframe, and I need to be able to stop it from the parent window, and it doesn't seem to be working. I'm assigning a global variable ('modelViewRefre
Solution 1:
Both clearInterval
and clearTimeout
require the iframe name
when called from outside the iframe.
HTML Example : <iframe name="iframe_0"></iframe>
JS Example :
iframe_0.clearInterval(modelViewRefresh)
To restart from the parent : modelViewRefresh=iframe_0.setInterval(do_this,1000)
Solution 2:
Iframes have their own window
object, meaning even if a variable is global in the iframe, it won't be accessible in the parent because parent and iframe do not share the same window
.
If you want to invoke a function in the iframe from the parent, I suggest you have a look at JSChannel or the jQuery postMessage plugin. It might be what you are looking for.
Post a Comment for "Need To Clearinterval In Iframe From Parent And It's Not Working"