Results 1 to 2 of 2

Thread: Reload the page if user isn't typing

  1. #1
    Join Date
    Jul 2011
    Posts
    56
    Thanks
    5
    Thanked 1 Time in 1 Post

    Default Reload the page if user isn't typing

    I need a script will reload the page every 10 minutes unless the user is typing. This also means even though the javascript function is in the middle of counting down, the script will restart the "count down" if the user is typing.

    Let me know where to start! I've been looking all over and I'm not that great at javascript!

    Thanks in advanced!

  2. #2
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,495
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    Code:
    <script type="text/javascript">
    // No Typing Reload Script (c)2012 John Davenport Scheuer
    // as first seen in http://www.dynamicdrive.com/forums/
    // username: jscheuer1 - This Notice Must Remain for Legal Use
    ;(function(){
    	var addEvent = (function(){return window.addEventListener? function(el, ev, f){
    			el.addEventListener(ev, f, false);
    		}:window.attachEvent? function(el, ev, f){
    			el.attachEvent('on' + ev, function(){f.call(el);});
    		}:function(){return;};
    	})(), timer;
    	function setreset(){
    		clearTimeout(timer);
    		timer = setTimeout(function(){location.reload(true);}, 1000 * 60 * 10);
    	}
    	addEvent(document, 'keydown', setreset);
    	setreset();
    })();
    </script>
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •