Help - Search - Members - Calendar
Full Version: Need Help With Some Coding
HTMLHelp Forums > Programming > Client-side Scripting
TDURHAM@CCA
Okay, So here is my Problem.
I am creating a website, that will be used on touch screen terminals.
i was wondering if there is any code that will allow the website to refresh to the homepage
after a certain amount of time of being inactive on a different page.

for example:
if the terminal has been inactive for 5 minutes on the Maintenance Page
the Page refreshes to the Home page.
zgillman
Put this in your <HEAD> section of the page
CODE
<META HTTP-EQUIV="REFRESH" CONTENT="300">

5 x 60 seconds = 300 seconds
Thats where you get the content="300" part...
pandy
Only the Meta redirect would happen either the user has been active or not...
zgillman
Oh true, then that might *beep* customers off by having it refresh each 5 minutes if they are in the middle of filling something out on the indexed page.. But you could make it work
pandy
JavaScript can do it, but I think it's pretty complicated, detecting clicks, scrolling and whatnot. I don't know how JavaScript fares with this kind of terminal.
Christian J
You could use a javascript timer that resets after each user interaction (such as keypress or mousemove on a traditional computer). Question is how to detect a touch screen interaction? FWIW, this is about the iPhone: http://www.quirksmode.org/blog/archives/20...one_events.html

And what if a user becomes interrupted for 5 minutes? Then an unwanted refresh would be annoying.
TDURHAM@CCA

Its hard to explain lol
i work for coca cola in Australia, and the homepage will have live data on how the production lines are running.
all other pages will be updates from the head of different departments such as OH&S, Maintenance, Engineering etc.... \
which will be assigned using contribute.

The big Bosses want the homepage to remain the Main screen, and if someone doesn't click back to the homepage they want it to
automatically go back.

That is why i am trying to get this activity sensor, casue i dont want it to divert back in the middle of someone reading something...
TDURHAM@CCA
QUOTE(Christian J @ Jan 11 2009, 08:59 AM) *

You could use a javascript timer that resets after each user interaction


Do you know the Code for this ?


QUOTE(Christian J @ Jan 11 2009, 08:59 AM) *

You could use a javascript timer that resets after each user interaction (such as keypress or mousemove on a traditional computer). Question is how to detect a touch screen interaction?


the touch screen will still have a pointer so the same code would apply



Christian J
QUOTE(TDURHAM@CCA @ Jan 22 2009, 05:22 AM) *

QUOTE(Christian J @ Jan 11 2009, 08:59 AM) *

You could use a javascript timer that resets after each user interaction


Do you know the Code for this ?


Try this:

CODE
<script type="text/javascript">
var time_lapsed=0;
function count_seconds()
{
    if(time_lapsed==300)
    {
        location.href='index.html'; // redirect
    }

    else
    {
        document.getElementById('x').value=time_lapsed; // can be removed along with the INPUT field
        time_lapsed++;
        setTimeout("count_seconds()",1000);
    }
}
window.onload=function()
{
    count_seconds();
    document.onclick=function(){time_lapsed=0;}
    document.onmousemove=function(){time_lapsed=0;}
    document.onscroll=function(){time_lapsed=0;}
    document.onkeydown=function() {time_lapsed=0;}

}
</script>

<input type="text" id="x">

Not sure if all the events are needed (or sufficient). If other scripts are already using window.onload you may need to start the script in some other way.
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Invision Power Board © 2001-2010 Invision Power Services, Inc.