Hello!
I would like to know if there a way to get the code below working as I intended (i.e. the div’s smoothly going up in stead of in one time with a one-second (100 * 10 milliseconds = 1 second) delay)
[code]<?xml version=”1.0″ encoding=”iso-8859-1″?>
<!DOCTYPE html PUBLIC “-//W3C//DTD XHTML 1.0 Transitional//EN” “http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd”>
<html xmlns=”http://www.w3.org/1999/xhtml” />
<head>
<title>airJX.com</title>
<script language=”JavaScript” type=”text/JavaScript”>
var Netscape = (window.Event) ? true : false;
var IExplore = (document.all) ? true : false;
function moveDiv(iLeft,iTop) {
if(Netscape) {
document.layers[‘div1’].left = parseInt(document.layers[‘div1’].left) + iLeft;
document.layers[‘div1’].top = parseInt(document.layers[‘div1’].top) + iTop;
document.layers[‘div2’].left = parseInt(document.layers[‘div2’].left) + iLeft;
document.layers[‘div2’].top = parseInt(document.layers[‘div2’].top) + iTop;
document.layers[‘div3’].left = parseInt(document.layers[‘div3’].left) + iLeft;
document.layers[‘div3’].top = parseInt(document.layers[‘div3’].top) + iTop;
}
if(IExplore) {
document.all.div1.style.left = parseInt(document.all.div1.style.left) + iLeft;
document.all.div1.style.top = parseInt(document.all.div1.style.top) + iTop;
document.all.div2.style.left = parseInt(document.all.div2.style.left) + iLeft;
document.all.div2.style.top = parseInt(document.all.div2.style.top) + iTop;
document.all.div3.style.left = parseInt(document.all.div3.style.left) + iLeft;
document.all.div3.style.top = parseInt(document.all.div3.style.top) + iTop;
}
}
function moveUp() {
for (a = 0; a <= 100; a++) {
pause(10);
moveDiv(0,-1);
}
}
function pause(iDelay) {
Temp = new Date();
iOld = Temp.getMilliseconds() + 1000 * Temp.getSeconds() + 60000 * Temp.getMinutes() + 3600000 * Temp.getHours();
iNew = 0;
while (iOld + iDelay > iNew) {
Temp = new Date();
iNew = Temp.getMilliseconds() + 1000 * Temp.getSeconds() + 60000 * Temp.getMinutes() + 3600000 * Temp.getHours();
}
}
</script>
</head>
<body>
<a onmousedown=”javascript:moveUp()”>Click this!</a>
<div id=”div1″ style=”position: absolute; left: 100px; top: 100px; height: 100px; width: 300px; background-color: 00FFFF;”>
Greetings!
</div>
<div id=”div2″ style=”position: absolute; left: 100px; top: 250px; height: 100px; width: 300px; background-color: 00FFFF;”>
Hello!
</div>
<div id=”div3″ style=”position: absolute; left: 100px; top: 400px; height: 100px; width: 300px; background-color: 00FFFF;”>
Bye now!
</div>
</body>
</html>
I think there should be somesort of refresh-action in the moveUp-function…