redcrazykid
Member
Code:
<html>
<head>
<style>
BODY { margin: 0px; padding: 0px; font-family: Courier New; font-size 8px; }
</style>
</head>
<body>
<div id="div2" style="margin:0px;padding:0px;position:absolute;left:200px;top:100px;border:1px solid #000000;width:600px;height:600px;">
<div id="div1" style="position:relative;left:0px;top:0px;width:8px;height:8px;background:#000000;"> </div>
</div>
<script>
try {
div1 = document.getElementById('div1');
sw = 600;
sh = 600;
dlc = 1;
dlc2 = 1;
dlc3 = 1;
dlc4 = 0;
function movediv1() {
dt = Math.floor(div1.style.top.toString().replace('px', ''));
if(dt > sh) {
return false;
}
dl = Math.floor(div1.style.left.toString().replace('px', ''));
dl = (dl + (dlc3 * dlc));
if(dl > sw || dl <= 0) {
dlc = dlc * -1;
if(dl > sw) {
dl = sw;
}
else {
if(dl <= 0) {
dl = 0;
}
}
dlc3 += 0.1;
dlc2 = dlc2 + 1;
div1.style.top = Math.round(dlc2) + 'px';
}
div1.style.left = Math.round(dl + dlc4) + 'px';
setTimeout('movediv1();', 0);
}
movediv1();
}
catch(errmsg) {
alert(errmsg);
}
</script>
</body>
</html>

