Jump to content

Search the Community

Showing results for tags 'setInterval()'.

  • 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. Hi there! I've built the following code snippet in order to animate a div element by using the setInterval() function to change the div element's height and width at a specified rate. the problem is that according to the arguments I've provided to the function, I've expected it to last 2 seconds. but unfortunately, actually the function executed during approximately 8 seconds and I don't understand why. please help me figure it out what is going here. <html><head><title></title><script type="text/javascript">try{function start(){var divFirst = document.getElementById("divFirst");var divControl = document.getElementById("divControl");function expand(eID, exHeight, exWidth, timing){i = 0;t = setInterval(innerExpand, timing);function innerExpand(){i++;eID.style.height = exHeight++;eID.style.width = exWidth ++;s = new Date();s = s.getSeconds();divControl.innerHTML = i + "---" + s;if(i == 1000){clearInterval(t);}//end if.}//end innerExpand().}//end expand().divFirst.onclick = function(){expand(divFirst, 20, 100, 2);}}//end start().}//end try statement.catch(err){alert("there's an error in this page. \n the error message is:\n" + err.message + "\n the error name is: \n" + err.name + "\n and the error details are:\n" + err.constructor + "\n and the error stack is: \n" + err.stack);}//end catch statement.</script><style type="text/CSS">div#divFirst {background-color:red;}div#divControl {position:absolute; top:10px; left:200px;}</style></head><body onload="start()"><div id="divFirst">my first div!!</div><div id="divControl"></div></body></html> Any help will be appreciated! Thanks in advance! atar.
×
×
  • Create New...