Solved

how do i reset a setTimeout?¿

Posted on 1997-05-29
4
1,053 Views
Last Modified: 2006-11-17
Can someone look over this and  tell me why its not working.
What I want it to do is to jump to another page after no activity for 5
minutes.  I want to turn the whole page into an image map so when the
mouse moves off an image it resets the timer. Please help!
heres what ive got so far:

<HTML>
<HEAD>
<TITLE>
</TITLE>

<SCRIPT LANGUAGE="JavaScript">
<!--hide me
self.name="only"
function goNext() {
open("timer2.html", "only");
}

function reSet() {
clearTimeout(myTimer);
}
//stop hiding-->
</script>
</head>
<body onLoad="myTimer= setTimeout('goNext()',5000)"><!---this is the
time in miliseconds-->

your image map or pictures go here,
be sure to have the "onMouseout" thing within the image tag

<img src="color_cube_colors.gif" onMouseout="reSet; goNext();">
<img src="color_cube_colors.gif" onMouseout="reSet; goNext();">
<img src="color_cube_colors.gif" onMouseout="reSet; goNext();">

</body>
</html>

THANKS
danny   mailto:impulse@usa.net

0
Comment
Question by:wired
  • 2
4 Comments
 

Expert Comment

by:gbingers
ID: 1265923
Did you try: onMouseOut="(reSet();goNext();)"

note the parentheses after reSet.
0
 

Author Comment

by:wired
ID: 1265924
thank you for trying, but that didnt work...please keep helping!
0
 
LVL 3

Accepted Solution

by:
garik earned 50 total points
ID: 1265925
First, let's change reSet() function - it should set a new timeout after clearing a previous one:

 function reSet() {
clearTimeout(myTimer);
myTimer = setTimeout('goNext()',5000);
}

Next, onMouseOut and onMouseOver events are generated only for the Link object; therefore, either make those images real image maps or put them inside the anchor:

<A HREF=/ onMouseOver='reSet()' onMouseOut='reSet()'>
    <IMG SRC='some.gif'>
</A>

I'd suggest to use both events to detect activity. In addition, onMouseOut has been introduced only in Netscape 3.0, so previous Netscape and MS IE dosn't understand it.

I hope I understood your problem correctly; if not, please comment on the answer before rejecting it :)

Cheers
0
 

Author Comment

by:wired
ID: 1265926
THANK you very much, that worked perfectly! u rock!
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Google Maps API and PHP 25 49
JavaScript Regex not working for 1-3 digit number?   /^\d{1,3}$/ 5 27
Diminish Pop-up  in 3 seconds 7 48
Responsive Font Size 6 27
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.
Boost your ability to deliver ambitious and competitive web apps by choosing the right JavaScript framework to best suit your project’s needs.
The viewer will learn the basics of jQuery, including how to invoke it on a web page. 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.: (CODE)
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…

861 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