Quote:
Originally Posted by rwcamera
The page appears when all the images are loaded, it works in all browsers less in SAFARI.
<script language="javascript">
<!--
function precargar() {
imgs = document.images;
precargadas = true;
for (var i = 0, total = imgs.length; i < total; i ++)
precargadas = (precargadas && imgs[i].complete);
if (precargadas) {document.body.style.visibility = "visible";}
else setTimeout("precargar()", 100);
}
//-->
</script>
<body onload="precargar()" style="visibility:hidden;">
</body>
The problem can be in:
Document.body.style? Safari does it refer otherwise to body?
Thank you for attending my problem.
|
Any console errors?
If Safari succeeds in hiding the page with CSS, presumably using visibility:hidden, it must accept document.body.style.visibility = "visible";
Have you tried alerting precargadas in the function?
This code is flawed because the final value of precargadas is dependent solely upon the .complete property of the last image.
Code:
for (var i = 0, total = imgs.length; i < total && imgs[i].complete; i ++)
;
precargadas= i==total;
if (precargadas)
{document.body.style.visibility = "visible";}
else
setTimeout("precargar()", 100);
Although even this is inadvisable because a load failure of any image will prevent display of the page.
Setting a timeout is pointless because the function is being called by the onload event, which fires when all images are either loaded or their loading has been abandoned.
I recommend using a script statement in the head section to hide the page initially (not CSS), then using the onload event to set the visibility of the page, regardless of the images' load status.
|