How to refresh an IFrame using Javascript?
Advertisement
How to refresh an IFrame using Javascript?
Question
I have a webpage with an IFrame and a Button, once the button is pressed I need the IFrame to be refreshed. Is this possible, if so how? I searched and could not find any answers.
2010/01/14
Accepted Answer
var iframe = document.getElementById('youriframe');
iframe.src = iframe.src;
2010/01/14
Popular Answer
This should help:
document.getElementById('FrameID').contentWindow.location.reload(true);
EDIT: Fixed the object name as per @Joro's comment.
2012/08/09
Read more... Read less...
provided the iframe is loaded from the same domain, you can do this, which makes a little more sense:
iframe.contentWindow.location.reload();
2018/11/22
Works for IE, Mozzila, Chrome
document.getElementById('YOUR IFRAME').contentDocument.location.reload(true);
2014/01/13
You can use this simple method
function reloadFrame(iFrame) {
iFrame.parentNode.replaceChild(iFrame.cloneNode(), iFrame);
}
2016/01/14
2017:
If it in on same domain just :
iframe.contentWindow.location.reload();
will work.
2017/11/20
Licensed under: CC-BY-SA with attribution
Not affiliated with: Stack Overflow
Email: [email protected]