Pb to moving a layer ...

  • Thread starter Antoine FESSARD
  • Start date
A

Antoine FESSARD

Hello every body

When I do a loop to move a layer, I have only the final position
In this exemple, I forget Netscape Javascript codes to simplify it

//********************
<HTML>
<HEADER>
<script Language="Javascript">
function moveLayer(MyLayer) {
var x=0;
var y=1;
var delay=0;
var TIMEDELAY=10000;
for (x=10 ; x<200 ; x+=1) {
document.all[MyLayer].style.left = x;
document.all[MyLayer].style.top = x;
for (delay=0 ; delay<TIMEDELAY ; delay++) ; // (juste to build a
small pause )
}
}
</script>

</HEADER>
<BODY>

<div id="theLayer"
style="position:absolute;top:400;width:150px;visibility:visible">Move-Me
!!!</div>

<script Language="Javascript">
moveLayer("theLayer");
</script>
</BODY>
</HTML>
 
T

Thomas 'PointedEars' Lahn

Antoine said:
When I do a loop to move a layer, I have only the final position
In this exemple, I forget Netscape Javascript codes to simplify it

//********************
<HTML>
<HEADER>
<script Language="Javascript">
function moveLayer(MyLayer) {
var x=0;
var y=1;
var delay=0;
var TIMEDELAY=10000;
for (x=10 ; x<200 ; x+=1) {
document.all[MyLayer].style.left = x;
document.all[MyLayer].style.top = x;
for (delay=0 ; delay<TIMEDELAY ; delay++) ; // (juste to build a
small pause )
}

Tight loops are certainly not an appropriate way to force a delay
since they depend on the processing speed of the executing system
and may still be removed by internal optimization. Instead, one
should set a timeout/interval (using the setTimeout/setInterval
method) to specify that an action (such as an animation) should
proceed/take place on specified timestamps from the time of setting.

Besides, your code is far from being valid HTML.
You cannot run on a swamp: <http://validator.w3.org/>


PointedEars
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,430
Messages
2,571,676
Members
48,796
Latest member
Greg L.

Latest Threads

Top