![]() |
|
Auto Refresh DIV without refreshing whole page - Printable Version +- Hack Forums (https://hackforums.net) +-- Forum: Tech (https://hackforums.net/forumdisplay.php?fid=444) +--- Forum: Webmasters (https://hackforums.net/forumdisplay.php?fid=141) +---- Forum: Website Construction (https://hackforums.net/forumdisplay.php?fid=50) +---- Thread: Auto Refresh DIV without refreshing whole page (/showthread.php?tid=4673707) |
Auto Refresh DIV without refreshing whole page - Tony Stark Sucks - Feb 6, 2015 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. * - Jokeh - Feb 6, 2015 Use jscript or Ajax I'll try find some code * - brewery - Feb 6, 2015 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 * - Jokeh - Feb 6, 2015 Here is some code Code htmlCode jscript(add Jquery)* - Tony Stark Sucks - Feb 6, 2015 I need it to auto refresh every 5 seconds, not from user input. * - Jokeh - Feb 6, 2015 Try this Code jscript(add Jquery)* - MoonCakeRuler - Feb 6, 2015 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();* - Sakuto - Feb 7, 2015 Maybe you should not use iFrame and start using real technology instead. * - Tony Stark Sucks - Feb 7, 2015 (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. |