PDA

View Full Version : Creating randomly sized/placed div boxes across screen.


sethwb
06-21-2009, 07:52 AM
I'm trying to have black boxes randomly appear across the screen with different sizes. There should be a random & slight delay between each boxes appearance. I'm building this from scratch but there is something I'm missing:


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<style type="text/css">
.boxb { color:ffffff; background-color: #000000; }
.boxf { color:000000; background-color: #ffffff; }
</style>

<script type="text/javascript">
var bg = document.getElementById('boxb');
var fg = document.getElementById('boxf');
var nwin = new Array();

function Creation() {

for (i=-576;i<1025;i++){
if(i<0) {
var slowDown = i*-1;
var slowDown2 = i*2;
}
else {
var slowDown2 = i*2;
}

var relax = setTimeout('mixedDiv()', slowDown);
var negIn = -576;

for ( i<negIn && i<1025) function mixedDiv(){
nwin2 = nwin[i];
document.createElement(”div”);
tnode.style.position = “absolute”;

// Create Random Number that changes each time i changes.
var randomnumber=Math.floor(Math.random()*1600)
var minuz = randomnumber - i;

tnode.id = "div" +1;
tnode.style.top = minuz + "px";
tnode.style.left = minuz + "px";
tnode.style.overflow = “hidden”;
tnode.style.width = i +"px";
tnode.style.height = i + "px";
tnode.createChild.textNode("I am child" + i);
tnode.style.z-index = i;
}
});
});
</script>
</head>
<body onload="Creation();">


</body>
</html>




What all am I doing wrong?