Home Articles FAQs XREF Games Software Instant Books About Feedback Search Site-Map
irt.org logo

Q342 How can I close a window after 10 seconds unless the mouse has moved, in which case I should suspend the closure for another 10 seconds?

irt.org | Knowledge Base | JavaScript | Window | Q342 [ previous next ]

Q342 How can I close a window after 10 seconds unless the mouse has moved, in which case I should suspend the closure for another 10 seconds?

Try something like this (Netscape Navigator 4 only):

<SCRIPT LANGUAGE="JavaScript"><!--
var timeoutID = '';

function restartTimer() {
    window.clearTimeout(timeoutID);
    startTimer();
}

function startTimer() {
    window.clearTimeout(timeoutID);
    timeoutID = window.setTimeout("close()",10000);
}

window.captureEvents(Event.MOUSEMOVE);
window.onMouseMove = restartTimer;
//--></SCRIPT>
 
<BODY onLoad="startTimer()">

Feedback on 'Q342 How can I close a window after 10 seconds unless the mouse has moved, in which case I should suspend the closure for another 10 seconds?'


Provide feedback ...
AddThis Social Bookmark Button

Provide feedback ... AddThis Social Bookmark Button


Last Updated: 30th March 2008. Maintained by: Martin Webb and Michel Plungjan
irt.org liability, trademark, document use, privacy statement and software licensing rules apply.
Copyright © 1996-2008 irt.org, All Rights Reserved.