How to reload an iframe in Javascript?

122 Views Asked by At

I am trying to reload an iframe. Normally the code is achieved without iframe via below code:

window.location.reload(true)

<iframe  src="https://maps.google.com/maps?f=q&amp;source=s_q&amp;hl=en&amp;geocode=&amp;q=eiffel+tower&amp;aq=&amp;sll=41.228249,-80.661621&amp;sspn=11.149099,23.269043&amp;ie=UTF8&amp;hq=&amp;hnear=Eiffel+Tower,+5+Avenue+Anatole+France,+75007+Paris,+%C3%8Ele-de-France,+France&amp;t=h&amp;ll=48.858186,2.294512&amp;spn=0.002471,0.00456&amp;z=17&amp;output=embed" id="iframeSupplierNumberSearch" height="200" width="300" title="Iframe Example"></iframe>

I have tried the following:

// var myFrame = document.querySelector('#iframeSupplierNumberSearch');
//var iframe = document.getElementById('iframeSupplierNumberSearch');
// myFrame.contentWindow.location.reload(true);   
// document.getElementById('iframeSupplierNumberSearch').contentWindow.location.reload()
//document.getElementById('iframeSupplierNumberSearch').src += '';

// document.getElementById('iframeSupplierNumberSearch').src = window.location.href; 

//document.getElementById('iframeSupplierNumberSearch').contentDocument.location.reload(true);
    
//document.getElementById('iframeSupplierNumberSearch').contentWindow.location.reload;
// window.frames['iframeSupplierNumberSearch'].location.reload(true);
//document.getElementById("iframeSupplierNumberSearch").src = window.location.reload();
//document.getElementsByTagName('iframeSupplierNumberSearch')[0].src = document.getElementsByTagName('iframeSupplierNumberSearch')[0].src
//  document.getElementById('iframeSupplierNumberSearch').contentWindow.location.reload();
// document.getElementById('iframeSupplierNumberSearch').contentWindow.location.reload;
// window.frames['iframeSupplierNumberSearch'].location.reload();
//window.location.href = window.location.pathname + window.location.search + window.location.hash;
//location = location;

Can you let me know how to reload the an iframe via windows.location.reload(true);?

0

There are 0 best solutions below