Click to See Complete Forum and Search --> : redirect inactive user


allsue
05-27-2003, 11:58 PM
I'm looking for some sort of script that would allow me to redirect a visitor after they have been inactive for a period of time. I guess the key word here is 'inactive' I've seen the meta tag and javascript codes that redirect after a certain amount of time but they do not suit my use.

Any help in this would be greatly appreciated.

Compguy Pete
05-28-2003, 12:28 AM
Are you using a CMS or are you using just regular HTML pages?

if your using just HTML your best bet would just to the page refresh meta tag after the amount of time you want.

if your using a CMS (Content Management System) I'm sure someone could help you write a plugin for it that would do that based on the user group for someone logged in.

So your next step is to mention a bit more about whats running your site.

Nevermore
05-28-2003, 02:54 AM
You could use a JavaScript that would run a timer and restart it if they click a link/scroll/move mouse whatever.

Nevermore
05-28-2003, 02:54 AM
You could use a JavaScript that would run a timer and restart it if they click a link/scroll/move mouse whatever.

allsue
05-29-2003, 05:05 PM
Do you have an example of that? Or does anybody else? I don't have a lot of skill with javascript. Although I do have know of the setTimeout command, just not with the link/scroll option that you are speaking of.

Nevermore
05-30-2003, 02:47 AM
Hee's a script to set a timer when the page is loaded, then restart it when the mouse is moved.


<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">

<html>
<head>
<title>Untitled</title>
<script type="text/javascript">
<!--
function timer() {
time1=window.setTimeout("alert('Times Up!')",5000);
}
function detime() {
window.clearTimeout(time1);
timer();
}
// -->
</script>
</head>
<body onload="timer()" onmousemove="detime()">

</body>
</html>

It will display an alert when the time runs out. At present the time is set to 5 secs. If you want to change what happens, then you need to change the red part to another JavaScript event. If you want to change the timer length, change the blue section. It is in milliseconds.

If you need more help, just ask.

allsue
06-01-2003, 03:09 AM
Thank you! I made one small change to achieve the results that I was looking for, but this was essentially it! I appreciate your help so much.

For inquiring minds, this is what I'm using:

<script type="text/javascript">
<!--
function timer() {
time1=window.setTimeout("redirect()",10000);
}

function redirect() {
window.location = "http://www.sitename.com/"
}

function detime() {
window.clearTimeout(time1);
timer();
}
// -->
</script>

I added the function redirect.