I need to auto refresh a div containing an iFrame, I've tried a lot of tutorials online and nothing I use works. Any help is appreciated, thanks.
Auto Refresh DIV without refreshing whole page |
|
Assuming you mean to refresh the content inside the <iframe /> in the manner that you would refresh your browser window, use the following JavaScript command:
Code document.getElementById('#myIframe').contentWindow.location.reload();Or switch out the document.getElementById("#myIframe") with a jQuery $("#myIframe") Hope this helps
Feb 6, 2015 05:36 PM
(This post was last modified: Feb 6, 2015 05:37 PM by Jokeh.)
Here is some code
Code htmlCode jscript(add Jquery)
I think something like this should work.
HTML: Code <iframe width='800' height='900' src='http://w3schools.com' id='w3frame'></iframe>JS: Code window.setInterval(function(){Working JS Fiddle: http://jsfiddle.net/d8c5t13x/ Reloads the Iframe every 5 secs. You might run into resource origin issues though. If same origin is enabled on the server, you can also do this: Code window.frames['nameoftheframe'].location.reload();(Feb 7, 2015 06:17 AM)Sakuto Wrote: Maybe you should not use iFrame and start using real technology instead.I have no control over that, the iFrame is a widget for a charity that I need updated every 5 seconds on a Twitch stream. |
|
|



