how to disable setInterval after someone clicks a specific link

Posted on 2009-05-19
Last Modified: 2013-11-19
hi all,
my manager wants me to make function called say x() execute each 4 seconds once after the page load then if specific link clicked no more executing the x function each 4 seconds

I'm newbie to this scenario can any body tell me how to do this scenario in syntax

best regards
hatem gamal
Question by:hatem_from_mesr

Accepted Solution

Devoney earned 500 total points
ID: 24419358
Make a .html file and put this code in their, open the file with your browser.



<SCRIPT LANGUAGE = "JavaScript">


var secs

var timerID = null

var timerRunning = false

var delay = 1000

function InitializeTimer()


    // Set the length of the timer, in seconds

    secs = 3




function StopTheClock()




    timerRunning = false


function StartTheTimer()


    if (secs==0)



        // Here's where you put something useful that's

        // supposed to happen after the allotted time.

        // For example, you could display a message:

        alert("You have just wasted 3 seconds of your life.")





        self.status = secs

        secs = secs - 1

        timerRunning = true

        timerID = self.setTimeout("StartTheTimer()", delay)





<body onload="InitializeTimer();">

<a style="cursor:pointer;" onClick="javascript:StopTheClock();" >Stop timer now</a>



Open in new window


Author Closing Comment

ID: 31582890
thanks man

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Browsers only know CSS so your awesome SASS code needs to be translated into normal CSS. Here I'll try to explain what you should aim for in order to take full advantage of SASS.
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
Viewers will learn about the regular for loop in Java and how to use it. Definition: Break the for loop down into 3 parts: Syntax when using for loops: Example using a for loop:
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.

919 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now