0

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);?

Brian Tompsett - 汤莱恩
  • 5,753
  • 72
  • 57
  • 129
Shanu Garg
  • 21
  • 3
  • I have tried all this.. it doesn't reload the iframe. Its just refresh the page. I need to reload the page not refresh it. – Shanu Garg May 12 '21 at 15:31
  • You're at the mercy of how the cache headers of the content within the iframe have been set. You could potentially append a timestamp to the querystring of the URL to avoid caching, if that's what you mean by 'reload not refresh'. – Rory McCrossan May 12 '21 at 15:35
  • document.getElementById('iframeSupplierNumberSearch').src += ''; does work, just use it in isolation. Check the console, you're probably getting a cross-origin error – Hive7 May 12 '21 at 15:35
  • @RoryMcCrossan I am using and iframe so that I can load parent window and see updated record on my parent screen. On calling via URL I can see only page which is written map.route and is by default. – Shanu Garg May 12 '21 at 15:58
  • @Hive7 it only takes the url written and refreshes it with empty string and what so ever is there in src will open again But I want to reload it not to refresh it. – Shanu Garg May 12 '21 at 15:59

0 Answers0