Solved

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

Posted on 2013-01-10
7
167 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
ID: 38765182
0
 
LVL 82

Expert Comment

by:leakim971
ID: 38765210
0
 

Author Comment

by:crm624
ID: 38765225
I'm talking about the setTimeout() Timing event to execute a function after so much time has gone by.
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
LVL 82

Expert Comment

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

Author Comment

by:crm624
ID: 38765320
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
ID: 38766597
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
ID: 38879051
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I've been trying to accomplish this for a while and it just struck me yesterday how to accomplish this task. I have done searches all over the internet looking for ways to email pages from my applications and finally I have done it!!! Every single s…
This article will give core knowledge of JavaScript and will head in to your first JavaScript program. I am Durvesh Naik and I am here to deal with this series of JavaScript. I will teach you JavaScript in part wise , as its quite boring to read big…
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…

910 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

21 Experts available now in Live!

Get 1:1 Help Now