What's the Best Way to Reload/Refresh an Iframe

What's the best way to reload / refresh an iframe?

document.getElementById('some_frame_id').contentWindow.location.reload();

be careful, in Firefox, window.frames[] cannot be indexed by id, but by name or index

How to refresh an IFrame using Javascript?

var iframe = document.getElementById('youriframe');
iframe.src = iframe.src;

Reload iframe using javascript

function reload( {
document.getElementById('iFrameID').contentDocument.location.reload(true);
}

Refresh page within an iframe

As stated in http://www.hyperorg.com/blogger/2007/03/24/refresh-an-iframe-in-ie-anyone/

HTML

<div id="wrapper"></div>

Javascript

function reload () {
var fr=document.getElementById('tehframe');
if(fr!=null) document.getElementById("wrapper").removeChild(fr);
var iframehtml="<iframe id='tehframe' src=…></iframe>";
document.getElementById("wrapper").innerHTML=iframehtml;
}

Then just call reload() at the beginning and whenever you want to load it.



Related Topics



Leave a reply



Submit