Pb to moving a layer ...

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Antoine FESSARD

    Pb to moving a layer ...

    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="Javas cript">
    function moveLayer(MyLay er) {
    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:4 00;width:150px; visibility:visi ble">Move-Me
    !!!</div>

    <script Language="Javas cript">
    moveLayer("theL ayer");
    </script>
    </BODY>
    </HTML>


  • Thomas 'PointedEars' Lahn

    #2
    Re: Pb to moving a layer ...

    Antoine FESSARD wrote:
    [color=blue]
    > 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="Javas cript">
    > function moveLayer(MyLay er) {
    > 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 )
    > }[/color]

    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.or g/>


    PointedEars

    Comment

    Working...