Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Reload an iframe without flickering/flash (in Javascript)

I would like to ask if anyone has a simple solution that will allow me to reload/refresh an iframe but without the flickering/flash when the page reloads, it that possible ? Maybe to animate a blur-out and then a blur-in instead of the flickering/flash? I don't know any input would be helpful,

Thanks.

Here is how I reload the iframe now

document.getElementById("FrameID").contentDocument.location.reload(true);

Thanks for the help.

like image 282
compcobalt Avatar asked Aug 07 '13 15:08

compcobalt


People also ask

How do I automatically refresh an iframe?

function refresh() { var iframe = document. getElementById('iframe'); iframe. reload(true); } setTimeout('refresh()', 3000); Note, this will try to refresh the page every 3 seconds.

How do you refresh a JavaScript frame?

To refresh an iframe using JavaScript, we call iframe. contentWindow. location. reload(); .


1 Answers

Easiest approach:

  1. Create a new iframe outside of DOM or in a hidden element.
  2. Load the page inside the hidden frame
  3. Once the load even fires within the hidden frame, just swap them around!

Swapping

To actually swap them, just have them next to each other and toggle the display: none / block css of each one.

like image 77
ZorleQ Avatar answered Oct 06 '22 00:10

ZorleQ