javascript efficiency

Discussion in 'ASP .Net' started by =?Utf-8?B?cm9kY2hhcg==?=, Sep 11, 2006.

  1. hey all,
    am i running the following javascript as fast as possible: All i'm trying to
    do is move an innerDIV via an outerDIV left and right. if i click real fast
    on the button it only moves one step after 2 clicks, if i click real slow it
    will move normal.

    <script type="text/javascript">
    var x // Gets innerDiv
    var y // Gets outerDiv
    var z; // Testing: Gets Label for testing purposes only
    var xValue=0; // Approximate position of scroll
    var count; // The maximum scroll width
    var Btn_Left // Scroll Left Button
    var Btn_Right // Scroll Right Button

    function BtnLeft_onclick() {
    inzsr();
    xValue+=100;
    x.style.left=xValue;
    z.innerText=xValue + ' ' + count;
    SetButtonStates()
    }
    function BtnRight_onclick() {
    inzsr();
    xValue-=100;
    x.style.left=xValue;
    z.innerText=xValue + ' ' + count;
    SetButtonStates();
    }
    function inzsr(){
    x=document.getElementById("SecondDiv");
    y=document.getElementById("FirstDiv");
    z=document.getElementById("Label1");
    Btn_Left=document.getElementById("BtnLeft");
    Btn_Right=document.getElementById("BtnRight");
    count=x.scrollWidth;
    SetButtonStates();
    }
    function SetButtonStates(){
    Btn_Right.disabled=(count+xValue<100)?true:false;
    Btn_Left.disabled=(xValue>=0)?true:false;
    }
    </script>
     
    =?Utf-8?B?cm9kY2hhcg==?=, Sep 11, 2006
    #1
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Bryan Krone

    perl efficiency -- fastest grepping?

    Bryan Krone, Nov 5, 2004, in forum: Perl
    Replies:
    1
    Views:
    1,487
    Jim Gibson
    Nov 8, 2004
  2. Trevor Hartman

    dataset efficiency question

    Trevor Hartman, Jul 3, 2003, in forum: ASP .Net
    Replies:
    0
    Views:
    404
    Trevor Hartman
    Jul 3, 2003
  3. Joseph D. DeJohn

    Custom Paging Efficiency

    Joseph D. DeJohn, Aug 6, 2003, in forum: ASP .Net
    Replies:
    1
    Views:
    361
    S. Justin Gengo
    Aug 6, 2003
  4. MC D
    Replies:
    4
    Views:
    473
    Big D
    Nov 18, 2003
  5. =?Utf-8?B?R2VvcmdlIER1cnpp?=

    Regex Efficiency Q - Manipulating Html

    =?Utf-8?B?R2VvcmdlIER1cnpp?=, Feb 28, 2004, in forum: ASP .Net
    Replies:
    0
    Views:
    309
    =?Utf-8?B?R2VvcmdlIER1cnpp?=
    Feb 28, 2004
Loading...

Share This Page