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

What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

Join & Write a Comment

Introduction Knockoutjs (Knockout) is a JavaScript framework (Model View ViewModel or MVVM framework).   The main ideology behind Knockout is to control from JavaScript how a page looks whilst creating an engaging user experience in the least …
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.
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

744 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

12 Experts available now in Live!

Get 1:1 Help Now