Jump to content

Search the Community

Showing results for tags 'setTimeout()'.

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

  • W3Schools
    • General
    • Suggestions
    • Critiques
  • HTML Forums
    • HTML/XHTML
    • CSS
  • Browser Scripting
    • JavaScript
    • VBScript
  • Server Scripting
    • Web Servers
    • Version Control
    • SQL
    • ASP
    • PHP
    • .NET
    • ColdFusion
    • Java/JSP/J2EE
    • CGI
  • XML Forums
    • XML
    • XSLT/XSL-FO
    • Schema
    • Web Services
  • Multimedia
    • Multimedia
    • FLASH

Find results in...

Find results that contain...


Date Created

  • Start

    End


Last Updated

  • Start

    End


Filter by number of...

Joined

  • Start

    End


Group


AIM


MSN


Website URL


ICQ


Yahoo


Jabber


Skype


Location


Interests


Languages

Found 2 results

  1. <!DOCTYPE hmtl><html lang = "en-US"> <head> <meta charset = "UTF-8"> <script type = "text/javascript"> window.onload = myFunction; var i = 11; function myFunction() { document.getElementById("output").innerHTML = display(); setTimeout(myFunction, 1000); } function display() { i--; var prompting; if (i == 0) { i = 10; prompting = confirm("Do you want to go?"); if (prompting == true) { window.location = "http://www.google.com"; } } return "You will be re-directed in " + i; } </script> </head> <body> <div id = "output"></div> </body></html> Hi guys, I just made this little countdown clock, but one thing is really confusing me, the setTimeout() function up there, it works fine, but whenever I replace it with setInterval(), the variable i doesn't step down by every 1 unit at all, instead, it goes like, 9 ....7....3, but when I use setTimeout(), it goes 10..9..8.. till 0. You guys know why? Thank you very much.
  2. In an attempt to build my own vertical scrolling display I have created the following function which works perfectly if I uncomment the alert() but fails to scroll vertically without that alert. function ScrollNumbers(Current) { var xpos = findPosY(document.getElementById("Unit")); if (xpos > 0) xpos *= -1;// alert("ScrollNumbers with "+" "+Current+" " + xpos); var CurrentUnit = parseInt(Current[Current.length - 2]); var Hoogte = 0; var a = 0; var c = 0; Hoogte = ((CurrentUnit)*94); // CurrentUnit can be anything from 0 to 9 Hoogte *= -1;// alert("Entering loop Hoogte = "+ Hoogte+" "+xpos); -700 -302 if (Hoogte < xpos) { while (Hoogte < xpos) { xpos += -1; document.getElementById("Unit").style.top = xpos+"px";// alert("1st Hoogte = "+ Hoogte+" xpos = "+xpos); a=window.setTimeout("c += 1",200);// doTimer(); } } else { if (Hoogte > xpos) // -302 -700 { while (xpos > -999) { xpos -= 1; document.getElementById("Unit").style.top = xpos+"px";// alert("2nd Hoogte = "+ Hoogte+" xpos = "+xpos); a=window.setTimeout("c += 1",200);// doTimer(); } xpos = 0; while (Hoogte < xpos) { xpos -= 1; document.getElementById("Unit").style.top = xpos+"px";// alert("3rd Hoogte = "+ Hoogte+" xpos = "+xpos); a=window.setTimeout("c += 1",200);// doTimer() } } } } What I get is that the new display appears without any delay rather than scroll into position.The way I see it is that the image should scroll from where it is now(xpos) to the new position one px at a time with 200msec between.
×
×
  • Create New...