Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > javascript efficiency

Reply
Thread Tools

javascript efficiency

 
 
=?Utf-8?B?cm9kY2hhcg==?=
Guest
Posts: n/a
 
      09-11-2006
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>
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
perl efficiency -- fastest grepping? Bryan Krone Perl 1 11-08-2004 11:15 PM
Efficiency of dynamically adding web user controls MC D ASP .Net 4 11-18-2003 07:27 PM
Custom Paging Efficiency Joseph D. DeJohn ASP .Net 1 08-06-2003 06:24 PM
CISCO 1721 efficiency problem DarejDok \(Dariusz Dħbrowski\) Cisco 0 07-16-2003 07:15 AM
dataset efficiency question Trevor Hartman ASP .Net 0 07-03-2003 08:20 PM



Advertisments