Solved

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

Posted on 2013-01-10
7
173 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Get 15 Days FREE Full-Featured Trial

Benefit from a mission critical IT monitoring with Monitis Premium or get it FREE for your entry level monitoring needs.
-Over 200,000 users
-More than 300,000 websites monitored
-Used in 197 countries
-Recommended by 98% of users

 
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

Optimize your web performance

What's in the eBook?
- Full list of reasons for poor performance
- Ultimate measures to speed things up
- Primary web monitoring types
- KPIs you should be monitoring in order to increase your ROI

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…
Boost your ability to deliver ambitious and competitive web apps by choosing the right JavaScript framework to best suit your project’s needs.
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…
Suggested Courses

617 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