Code Snippet

Home » Code Snippets » HTML » Get Rid of White Flash when iframe Loads

Get Rid of White Flash when iframe Loads

Hides iframe until fully loaded.

<iframe style="visibility:hidden;" onload="this.style.visibility = 'visible';" src="../examples/inlineframes1.html" > </iframe>

Subscribe to The Thread

  1. Exactly what I needed! Didn’t know this was possible.

  2. Thankee Jesus!!!!

  3. sonja

    thank YOU!!!!

  4. Why doesn’t it work for me? I have 3 pages with iframes: archive, current and black white series

    When I look in IE 7 or 8 the white box still flashes… ???

  5. Your code will keep the iframe hidden if javascript is disabled. This one will only hide/show the frame if javascript is enabled.

    //iframe flashes white bugfix with jquery
    //set visibility to ‘hidden’ in the actual page
    $(“iframe”).load(function() {
    $(this).css(“visibility”, “visible”);
    });
    $(“iframe”).ready(function() {
    $(this).css(“visibility”, “hidden”);
    });

  6. Hi,

    Is there any chance you could tell me how/where would I integrate this in Facybox?

    Many thanks

  7. works fine !! thx a lot – greetings from austria – jodeldijodeldiö

  8. Any W3C valid solution?

  9. Paul

    Love you. Thats just simple genius

  10. JDPaulsen

    It does work, however it works only once. After the iFrame-constructed page loads, if you click on a link that it’s supposed to load another page on said iFrame, and because said iFrame is already loaded and hence visible, the white Flash is back.

  11. Kapy

    struggles with this problem in fancybox for ages,
    go to the fancy box jacked.js

    look for first occurance of “<iframe"

  12. Kapy

    wont let me post full html:
    id=”fancybox-frame” name=”fancybox-frame’+(new Date).getTime()+’” frameborder=”0″ hspace=”0″ allowtransparency=”true” style=”visibility:hidden;” onload=”this.style.visibility = \’visible\’;” scrolling=”‘+e.scrolling+’” src=”‘+d.href+’”

  13. Kapy

    You need to do 3 things really:
    make iframe invisible, in css “visible:hidden”
    make iframe allow transparency, allowtransparency=”true”
    make the body it displays have a transparent background, “background-color:transparent”

  14. Pest

    Thank you so much! This works very well! It’s ridiculous how Internet Explorer 9 STILL shows a white background for iframes during page load! Unbelievable.

  15. rttmax

    thx. so easy…

  16. Thanks a million. I wasted hours trying to figure this out. A simple solution that works.

Speak, my friend

At this moment, you have an awesome opportunity* to be the person your mother always wanted you to be: kind, helpful, and smart. Do that, and we'll give you a big ol' gold star for the day (literally).

Posting tips:
  • You can use basic HTML
  • When posting code, please turn all
    < characters into &lt;
  • If the code is multi-line, use
    <pre><code></code></pre>
Thank you,
~ The Management ~