/    Sign up×
Community /Pin to ProfileBookmark

setInterval not persistent when user leaves page and returns to it via "back" button

Is there any reason why when a user loads a page with a setInterval, then leaves the page and returns to it via the BACK button of the browser, that the page now no longer has the setInterval stuff running?

to post a comment
JavaScript

6 Comments(s)

Copy linkTweet thisAlerts:
@gil_davisDec 04.2002 — Pressing the "back" button causes the window to reload a page from it's history. A reload causes all parameters for that page to be initialized. It's like pressing reset on your computer. Only functions in the onLoad event will start. There is no "memory" other than the URL of the page that resides in the history.
Copy linkTweet thisAlerts:
@Doug_DyerauthorDec 04.2002 — Thanks for the reply.

Thats what I thought, but when I have three frames, each with a setInterval, sometimes flipping forward and back with my main frame causes some of the surrounding frames to stop doing their interval.

Could be something else going on.
Copy linkTweet thisAlerts:
@Zach_ElfersDec 04.2002 — Actually, I don't think hitting back reloads the page. For example. You click a link and that anoying dotted line appears around it and you go to the next page. You hit back and the outline is still there.?
Copy linkTweet thisAlerts:
@gil_davisDec 04.2002 — [i]Originally posted by Zach Elfers [/i]

[B]Actually, I don't think hitting back reloads the page.[/B][/QUOTE]


Well, what would you call it?

Whatever it is, the last state of the page is not retained. Some browsers will return you to your place, and the dotted line around the link is a visual cue to tell you the last link you clicked on in the page - a totally different situation from a JS function running.
Copy linkTweet thisAlerts:
@gil_davisDec 04.2002 — [i]Originally posted by Doug_Dyer [/i]

[B]when I have three frames, each with a setInterval, sometimes flipping forward and back with my main frame causes some of the surrounding frames to stop doing their interval.[/B][/QUOTE]


Maybe a bug. Is the code in the frameset or in each frame? Are you getting any JS errors?
Copy linkTweet thisAlerts:
@Doug_DyerauthorDec 04.2002 — No, no JS errors.

The code is within a <SPAN> area at the top of each src file for each frame.

On an onload, I do setInterval on my routine. The javascript for each frame involves loading javascript files from the server that in turn do something dynamic to the respective frame.

Hence, every few seconds each frame should do something.

For some reason, every once in a while Ill go "back" and nothing changes unless I do a page reload.
×

Success!

Help @Doug_Dyer spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.7,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...