Home Upgrade Search Memberlist Extras Hacker Tools Award Goals Help Wiki Contact

Auto Refresh DIV without refreshing whole page

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.
Use jscript or Ajax I'll try find some code
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
Here is some code

Code
html

<div id="res">Primary content</div>
<input type="button" value="rel"></input>

Code
jscript(add Jquery)

$(document).ready(function(){
$("#rel").click(function(){
$("#res").html(ajax_load).load(loadUrl);
});
});
I need it to auto refresh every 5 seconds, not from user input.
Try this
Code
jscript(add Jquery)

$(document).ready(function(){
$("#rel").click(function(){
$("#res").html(ajax_load).load(loadUrl);
}, 3000);
});
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(){
    document.getElementById('w3frame').src = 'http://w3schools.com';
}, 5000);

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();
Similar to what edgedev has suggested already. Hope that helps.
Maybe you should not use iFrame and start using real technology instead.
(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.


Possibly Related Threads...
Thread / Author Replies Views Last Post
by EffexionApr 15, 2021 05:12 AM 10 278 Apr 15, 2021 05:12 AM
Last Post: Goku
by CarrotDec 24, 2020 12:16 PM 0 244 Dec 24, 2020 12:16 PM
Last Post: Carrot
by craigOwnsYouOct 31, 2019 01:13 PM 0 103 Oct 31, 2019 01:13 PM
Last Post: craigOwnsYou