views:

402

answers:

2

Hi Guys,

I am using an iframe in my project and it seems that whenever it loads content on a opacity background - it flashes "white" for around 1 second before correctly appearing.

It seems that it fires loaded event before the jQuery script is ready. I have tried

style="visibility:hidden;" onload="this.style.visibility = 'visible';"

but doesn't work. Any other ideas to get rid of this ?

+1  A: 

Try using:

style="display:none" onload="this.style.display = 'block';"

visibility:hidden doesn't actually "hide" the element as such - it still takes up the space it would if it were visible. display:none actually makes the element completely invisible, as if it doesn't exist.

Lucas Jones
thx a lot this seem to help ))
Thomas
No problem. I had a similar issue when I first learned about `visibility: hidden`. :)
Lucas Jones
A: 

It looks like this trick does not work on every browser, as explained here: http://it-things.com/index.php/2010/09/iframe-loading-white-background/

Anyone knows something that works also on Chrome/Safari?

Joao Pinto