Solved

Is it possible to have setTimeout not restart when going to different pages on the site?

Posted on 2013-01-10
7
166 Views
Last Modified: 2013-02-11
If I have setTimeout in a script in the header of my site is it possible to have it continue to run as a user goes from page to page without restarting. Is this something I could use cookies to do? Are there any examples I could look at?
0
Comment
Question by:crm624
  • 3
  • 3
7 Comments
 
LVL 82

Expert Comment

by:leakim971
Comment Utility
0
 
LVL 82

Expert Comment

by:leakim971
Comment Utility
0
 

Author Comment

by:crm624
Comment Utility
I'm talking about the setTimeout() Timing event to execute a function after so much time has gone by.
0
Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

 
LVL 82

Expert Comment

by:leakim971
Comment Utility
yes, the answer to your question is no, you can't
0
 

Author Comment

by:crm624
Comment Utility
Wouldn't it be possible to time the user and store it in a cookie and then add to the cookie when they go to a different page? Then have the function execute when it gets to a certain time.
0
 
LVL 9

Accepted Solution

by:
Sar1973 earned 500 total points
Comment Utility
Even if you name a setTimeout variable or not, it is supposed to reset on page exit even if you do not use the clearInterval method.
What you ask is to pass the variable value to a page from another and use it as the initial value instead of 0 in order to have a cumulative value instead; you could use the addEventListener and postMessage methods (see http://robertnyman.com/2010/03/18/postmessage-in-html5-to-send-messages-between-windows-and-iframes/, http://msdn.microsoft.com/en-us/library/bb979674(v=VS.95).aspx and http://stackoverflow.com/questions/256754/how-to-pass-arguments-to-addeventlistener-listener-function).
0
 

Author Comment

by:crm624
Comment Utility
I was able to pass the value of a timer I made and use cookies to start from where it left off.
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

In this article, we'll look how to sort an Array in JavaScript, including the more advanced techniques of sorting a collection of records either ascending or descending on two or more fields. Basic Sorting of Arrays First, let's look at the …
The task A number given should be formatted for easy reading by separating digits into triads. Format must be made inline via JavaScript, i.e., frameworks / functions are not welcome. So let’s take a number like this “12345678.91¿ and format i…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

6 Experts available now in Live!

Get 1:1 Help Now