@ user247245: From your question it is not entirely clear how you (want) to use iframe. Does it reload periodically or once when the entire web page loads?
Solution 1: Background Color
If you just want to avoid the ugly white and avoid over complication. Set a different background color in the HTML header of the framecontents.html file, for example:
<!DOCTYPE html> <html style="background-color: #F48;">
Thus, while the CSS file is being loaded, parsed and applied, the background is not #fff .
Solution 2: Transparent iframe
As long as there is no content, the iframe just should not be visible. Decision:
<iframe src="/framecontents.html" allowTransparency="true" background="transparent"></iframe>
Of course, do not use this in combination with solution 1, you shoot in the foot.
Solution 3: Preload the iframe page
If you download the iframe later (for example, the user by clicking the link), consider preloading its contents. Hide this at the top of the page (of the parent):
<iframe src="/framecontents.html" style="position: absolute; width: 0px; height: 0px"></iframe>
But I would advise using solution 2 instead.
Solution 4. If you are running a mobile web interface:
See how jQuery Mobile did it. We created a web interface that was supposed to look like a native application, so without rebooting. jQM fixed this. Basically makes an ajax background call to retrieve the full HTML content, and then extracts the body (the “page” div to be more precise), and then replaces the content (with a jump if you like). The countdown is displayed all this time.
In general, it looks like a mobile application: rebooting does not reboot. Other solutions:
Solution 5: use JS to enter CSS:
See jmva's answer or http://css-tricks.com/prevent-white-flash-iframe/ .
Solution 6: use JS to enter CSS (simple version)
<script type="text/javascript"> parent.document.getElementById("theframe").style.visibility = "hidden"; </script> <iframe id="theframe" src="/framecontents.html" onload="this.style.visibility='visible';"></iframe>
You could, of course, leave the <script> and add style="visibility:hidden;" in the iframe, but the above will guarantee that the frame will be visible to visitors with JS disabled. In fact, I would advise you to do this, because 99% of visitors included it in any case, and its simpler and more effective.