Javascript setTimeout-recursion doesn't work with Chrome and Firefox -



Javascript setTimeout-recursion doesn't work with Chrome and Firefox -

the code below sliding div within hidden overflow div (concept future website). text box below "next" , "previous" links indicating x value. ie8 works fine.

with chrome , firefox seems function 1 time (one step) both "next" , "prev", means settimeout doesn't run.

<html> <meta http-equiv="content-script-type" content="text/javascript"> <head> <script type="text/javascript"> var ie5 = (document.all && document.getelementbyid); var ns6 = (!document.all && document.getelementbyid); function next(startx, fadestep, end){ if(startx > end){ startx -= math.round((1/math.pow(fadestep,0.6))); if (startx < end) startx = end; document.getelementbyid('lastname').value = startx + "px"; document.getelementbyid('test1').style.left = startx + "px"; fadestep += 0.00035; args = "next(" + startx + "," + fadestep + "," + end + ")"; settimeout(args, 20); } } function prev(startx, fadestep, end){ if(startx < end){ startx += math.round((1/math.pow(fadestep,0.6))); if (startx > end) startx = end; document.getelementbyid('lastname').value = startx + "px"; document.getelementbyid('test1').style.left = startx + "px"; settimeout('prev(' + startx + ',' + (fadestep+0.00035) + ',' + end + ')', 20); } } </script> </head> <body> <div style="position:relative;width:570;height:78;overflow:hidden"> <div id="test1" style="position:absolute;left:0px;top:0px;width:1180;height:78"> <img src="http://img38.imageshack.us/img38/7225/imageva.png" border=1> <img src="http://img577.imageshack.us/img577/5554/image2te.png" border=1> </div> </div> <div style="position:absolute;left:900px;top:0px;width:800"> <a href="#" onclick="next(0, 0.001, -570)">next</a><br /> <a href="#" onclick="prev(-570, 0.001, 0)">previous</a></ br> <form><input type="text" id="lastname" value="gfgfg"/></form> </div> </body> </html>

can please assist?

it might improve way, in case, utilize settimeout following:

window.settimeout(function() { next(startx, fadestep, end); } , delayinmiliseconds);

however, lack of "window." object prefix might cause of functionality not working in these browsers.

if have other questions don't hesitate ask.

as stated in comments save deal of time utilize jquery.

best regards,

javascript google-chrome recursion settimeout

Comments

Popular posts from this blog

How do I check if an insert was successful with MySQLdb in Python? -

delphi - blogger via idHTTP : error 400 bad request -

postgresql - ERROR: operator is not unique: unknown + unknown -