Click to See Complete Forum and Search --> : Countdown - How?
Hi There.
How can create an inner clock (in JS) that will show an alert message if the user is in the same page for more then 5 minutes (for session purpose) and I after he'll click on "OK" he'll forward to a different page.
Thanks!
gil davis
08-24-2004, 02:36 PM
<script>
var timer = setTimeout("leave()", 5 * 60*60*1000);
function leave() {
alert("Time's up!");
window.location.href = "newpage.htm";
}
</script>
glenmac
08-24-2004, 09:15 PM
It would take quite awhile to fire with the timeout setting anyway, like 5 hours. This will work for you I hope.
<html>
<head>
<script>
function leave() {
alert("Time's up!");
window.location.href = "newpage.htm";
}
function go(){
setTimeout("leave()",5*60*1000);
}
</script>
</head>
<body onLoad = "go()">test for time out
</body>
</html>
nitwit
08-24-2004, 09:20 PM
5 hours is a long time...:D
<script type="text/javascript">
setTimeout(
function()
{
alert('Your five minutes are up.');
self.location = 'redirect_url';
} ,
300000);
</script>
glenmac
08-24-2004, 09:35 PM
a much cleaner solution nitwit!!!
gil davis
08-25-2004, 06:09 AM
D'oh!