Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 176
  • Last Modified:

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

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
crm624
Asked:
crm624
  • 3
  • 3
1 Solution
 
leakim971PluritechnicianCommented:
0
 
leakim971PluritechnicianCommented:
0
 
crm624Author Commented:
I'm talking about the setTimeout() Timing event to execute a function after so much time has gone by.
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
leakim971PluritechnicianCommented:
yes, the answer to your question is no, you can't
0
 
crm624Author Commented:
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
 
Sar1973Commented:
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
 
crm624Author Commented:
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

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

  • 3
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now