Solved

window.clearTimeout() in IE3

Posted on 1998-11-02
8
246 Views
Last Modified: 2008-02-20
The window.clearTimeout() method doesn't seem to work in IE3, is it part of IE3s Jscript? and if it isn't how can I stop a function called by a window.setTimeout() coming into effect?

Any help would be greatly appreciated.
0
Comment
Question by:jtp101
  • 4
  • 3
8 Comments
 
LVL 4

Expert Comment

by:martinag
ID: 1273419
I don't know if clearTimeout() is defined or not (it could be some problem with your other code) but if it is not you could use a variable:

timerId = setTimeout('runByTheTimer()', 1000);
runTimer = 1;
.
clearTimeout(timerId);
runTimer = 0;
.
function runByTheTimer() {
  if (!runTimer) return;
  ...
}

Martin
0
 
LVL 8

Expert Comment

by:jbirk
ID: 1273420
clearTImeout should work fine in IE 3.  Martin's code should work for you though if the clearTimeout still doesn't work.

Just out of curiosity though, what's your code look like?  I was just wondering if maybe it was coded wrong or something.
-Josh
0
 

Author Comment

by:jtp101
ID: 1273421
Hi there Josh

This is the part of the code which gives me the error.

The idea is that when a user of my site moves their mouse pointer over an image, help text for that image is displayed in another
frame.

when the mouse is moved over the image, helptextchange() is called which puts the correct file in the help text window and sets
up a window.setTimeout() to change the help text window back to normal after 6 seconds, the problem is that if the mouse
pointer is moved over another image, say 5 seconds after the first, the new helptext is called up and 1 second later taken away
(because the first window.setTimeout() is still active) therefore I need to cancel the first window.setTimeout().

I would have liked to use a "onMouseOut" to change the text back to normal bu that isn't supported my IE3 either.

Code Below:

var htbtn=null;

function helptextchange(thehelptextfilename) {

parent.helptext.location.href= "http://www.jtp.dircon.co.uk/whisky/helptext/" + thehelptextfilename;

window.clearTimeout(htbtn);
htbtn = window.setTimeout('helptexttonormal()',6000);
 }
}


function helptexttonormal() {

parent.helptext.location.href= "http://www.jtp.dircon.co.uk/whisky/helptext/helptext.htm";

}

From
  Justin
0
 

Author Comment

by:jtp101
ID: 1273422
Hi Martin

Thanks for your comment, but at the same time as the first setWindowTimeout() is cancelled I need to create another setWindowTimeout() assigned to the same variable as the first one, and that won't come into effect either using your method (because runTimer would be equal to 0, and if you didn't set it to 0 the first setWindowTimeout() would still come into effect).

Have a look at my code in the other comment I have posted if you're interested.

Thanks again

From
  Justin
0
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.

 
LVL 8

Expert Comment

by:jbirk
ID: 1273423
OK, I'm not sure if this will work, but try this:

counter=0;
function helptextchange(thehelptextfilename)
 {parent.helptext.location.href= "http://www.jtp.dircon.co.uk/whisky/helptext/" +                                             thehelptextfilename;
 counter++;
  window.setTimeout('helptexttonormal()',6000);
 }

function helptexttonormal()
 {counter--;
  if (counter==0)
   parent.helptext.location.href= "http://www.jtp.dircon.co.uk/whisky/helptext/helptext.htm";
 }

The theory is right, so if I had the semantics slightly off and it doesn't work, I'll try to fix it by actually testing with dummy pages.

Good luck,
Josh
0
 

Author Comment

by:jtp101
ID: 1273424
Hi Josh

Sorry I disappeared (Had to go away for a few days)

Your method should work perfectly! so if you re-post it as a proposed answer then I will
give you the points.

Thanks very much.

From
   Justin

P.S. any Idea why the clearTimeout() is not working?
0
 
LVL 8

Accepted Solution

by:
jbirk earned 10 total points
ID: 1273425
Glad it worked for you!
I really have no idea why clearTimeout() didn't work for you.  It's supposed to be supported by all versions of javascript enabled browsers.

-Josh
0
 

Author Comment

by:jtp101
ID: 1273426
Cheers Josh.
0

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

JavaScript can be used in a browser to change parts of a webpage dynamically. It begins with the following pattern: If condition W is true, do thing X to target Y after event Z. Below are some tips and tricks to help you get started with JavaScript …
Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult to…
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…

911 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

21 Experts available now in Live!

Get 1:1 Help Now