PDA

View Full Version : Timer stops when click-and-hold browser close



VorlonShadow
Oct 23rd, 2009, 03:27 PM
We have a testing application that displays a timer on the screen using Javascript. It seems to be working very well. However, someone brought to my attention today that if you click-and-hold the browsers close button in the upper right corner (the X button in Windows) that the timer will stop. You can then slide your mouse cursor off of the button, and the browser will not close, but the timer was stopped for the entire time that the button was being held down. This also works for the Minimize and Maximize buttons.

Is there any way at all to take care of this problem?

Thanks,
Jesse

Kor
Oct 23rd, 2009, 03:32 PM
You should have sensed that we can not give you an answer since we can not reproduce that "error". Give us a link to a test code, or the code itself. And, moreover, tell us which browser type does what it does?

Philip M
Oct 23rd, 2009, 03:33 PM
Which browser? I cannot replicate this in IE.

Quizmaster: In nature, what invertebrate has a name which literally means "one hundred feet"?
Contestant: Giraffe

VorlonShadow
Oct 23rd, 2009, 04:28 PM
OK. I've put together a little sample of this issue. You can view it here:

http://www.answerwrite.com/timertest.htm

This is a problem with FireFox and Opera, but doesn't seem to be an issue with Internet Explorer and Chrome. I haven't tested Safari.

Thanks,
Jesse

Philip M
Oct 23rd, 2009, 06:28 PM
Well, we learn something new every day! Strange that no-one has noticed this before! The problem affects IE as well, and not just your script but all my other count down scripts. It only applies when the close button is a red X (a window less than full screen). The timer remained stopped until I released the mouse button, not just until the mouse pointer was moved outside the X box. If the script is run in full screen mode with a black X then the problem disappears. So it is a Windows bug, not JavaScript or the browser.

As you say, the Maximise and Minimize buttons do the same.

An interesting discovery - may create problems for timed quizzes! We have had a few of these recently in the forum!

VorlonShadow
Oct 23rd, 2009, 06:41 PM
Exactly.... which is exactly what we are. I tried maximized in FireFox, and the problem still existed. It's too bad that this is a browser bug, and no work around. Some kid will figure this out and finish a 60 minute test in "2 minutes".

Jesse

Kor
Oct 23rd, 2009, 07:13 PM
Yeap... I guess we should:

- check if only setTimeout() method is affected. Give it a try with setInterval()
- check if any sequential javascript code is affected (long loops)
- check if a combined server-side + client-side counter is affected

Boyz'n'Girlz, I guess we have some work to do :)

Philip M
Oct 24th, 2009, 09:12 AM
Same with setInterval() :(

I think that clicking on or "holding down" the button(s) suspends execution of all the code.