I have a script that loads random backgrounds every time the page is reloaded (or refreshed). It works really well — except it randomly produces a BLANK page. I’ve tried to figure it out for the past three weeks. I even passed it through several “javascript code testers” without resolve.
Here is the WHOLE PAGE:
[code]
<!DOCTYPE html PUBLIC “-//W3C//DTD HTML 4.01 Transitional//EN”>
<html>
<head>
<title>REFRESH PAGE TEST</title>
<script type=”text/javascript”>
var backgr = [‘bg0.png’,’bg1.png’,’bg2.png’,’bg3.png’,’bg4.png’,’bg5.png’,’bg6.png’,’bg7.png’,’bg8.png’,’bg9.png’,’bg10.png’,’bg11.png’,’bg12.png’,’bg13.png’];
var cur = Math.round((backgr.length)*Math.random());
document.write(‘<body background=”‘+backgr[cur]+'”>’);
var backgrounds = [‘bg0.png’,’bg1.png’,’bg2.png’,’bg3.png’,’bg4.png’,’bg5.png’,’bg6.png’,’bg7.png’,’bg8.png’,’bg9.png’,’bg10.png’,’bg11.png’,’bg12.png’,’bg13.png’],
bg,
cur = Math.round((backgrounds.length)*Math.random());
document.body.style.backgroundImage=backgrounds[cur];
document.body.style.backgroundPosition=”top center”; // can be changed to anything else (e.g. bottom center, top left, center right…)
document.body.style.backgroundRepeat=”no-repeat”;
</script>
<style type=”text/css”>
<!–
body {background-repeat: no-repeat;}
–>
</style>
</head>
<body onload=”onloadBg”>
Page content….bla, bla, bla
</body>
</html>
I’d give you a URL to look at; but, I’m using it to build a DVD for my grandaughter’s Christmas present.