Home Articles FAQs XREF Games Software Instant Books BBS About FOLDOC RFCs Feedback Sitemap
irt.Org
#

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?

You are here: irt.org | FAQ | JavaScript | Window | Q342 [ previous next ]

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?'

©2018 Martin Webb