Wrox Programmer Forums
|
Javascript General Javascript discussions.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Javascript section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old September 22nd, 2003, 02:35 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 101
Thanks: 0
Thanked 1 Time in 1 Post
Send a message via AIM to Moharo
Default javascript functions

hello there fellows

i got a question regarding functions in JavaScript. how can i stop executing a function
which calls itself using setTimeout() method. For example, consider following functions:

var time = 0;

function start()
{
    //start the timer
    time++;
    setTimeout("start(" + time + ")",1000);
}

function resetTimer()
{
    time = 0;
    return time;
}


now if i call the start() function for the first time, there's no problem but when i call resetTimer() and then again start() function,
the timeout seems to be going crazy fast - it doesn't increment time variable every second but it gets a lot faster. Every time i call start() function, time variable gets increased much faster every 1 second. I think you know what i mean. what i want is to call start function even million times but still the time variable will increase every second.

thanx :D:D


the genuine genius
__________________
www.campusgrind.com - college portal
 
Old September 23rd, 2003, 01:04 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 996
Thanks: 2
Thanked 11 Times in 11 Posts
Send a message via Yahoo to melvik
Default

I had no problem! of course by changeing a liitle bit ur code!!!
1. u used the start by argument but there is no parameter in creation!
2. u can use start function in setTimeout() without any () like: setTimeout(start, 1000);
3. I had problem in using start name for my function. what is ur Browser & version?!

Always:),
Hovik Melkomian.





Similar Threads
Thread Thread Starter Forum Replies Last Post
Javascript functions and xslt 1.0 variable mlohokare XSLT 18 December 3rd, 2008 02:22 AM
stop current javascript function using javascript sakthi Javascript 3 June 2nd, 2008 03:30 PM
Dynamically call javascript functions austinf Javascript 1 May 13th, 2006 07:31 AM
functions xelepi PHP How-To 1 March 10th, 2006 02:59 AM
Executing from JavaScript C# functions see07 ASP.NET 1.x and 2.0 Application Design 1 March 1st, 2005 07:02 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.