Solved

how to disable setInterval after someone clicks a specific link

Posted on 2009-05-19
2
1,042 Views
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
0
Comment
Question by:hatem_from_mesr
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 1

Accepted Solution

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


<html>
<header></head>
 
<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
    StopTheClock()
    StartTheTimer()
}
 
function StopTheClock()
{
    if(timerRunning)
        clearTimeout(timerID)
    timerRunning = false
}
 
function StartTheTimer()
{
    if (secs==0)
    {
        StopTheClock()
        // 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.")
	InitializeTimer()
    }
    else
    {
        self.status = secs
        secs = secs - 1
        timerRunning = true
        timerID = self.setTimeout("StartTheTimer()", delay)
    }
}
//-->
</SCRIPT>
 
 
<body onload="InitializeTimer();">
<a style="cursor:pointer;" onClick="javascript:StopTheClock();" >Stop timer now</a>
</body>
</html>

Open in new window

0
 

Author Closing Comment

by:hatem_from_mesr
ID: 31582890
thanks man
0

Featured Post

PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Why is my $_POST not going to results page 10 65
Check input text, Number 7 53
Scroll 5 news at a time using vticker 2 38
Sticking text to shapes in Raphael.js 6 37
Preface This is the third article about the EE Collaborative Login Project. A Better Website Login System (http://www.experts-exchange.com/A_2902.html) introduces the Login System and shows how to implement a login page. The EE Collaborative Logi…
This article discusses how to create an extensible mechanism for linked drop downs.
The viewer will receive an overview of the basics of CSS showing inline styles. In the head tags set up your style tags: (CODE) Reference the nav tag and set your properties.: (CODE) Set the reference for the UL element and styles for it to ensu…
The viewer will the learn the benefit of plain text editors and code an HTML5 based template for use in further tutorials.

738 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