Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.javascript > #30425
| From | Tuxedo <tuxedo@mailinator.com> |
|---|---|
| Newsgroups | comp.lang.javascript |
| Subject | Re: window.onload not working when using Safari's back button |
| Date | 2016-05-11 21:39 +0200 |
| Organization | albasani.net |
| Message-ID | <nh01q5$ku8$1@news.albasani.net> (permalink) |
| References | <ngthoj$v4f$1@news.albasani.net> <6p5if990m1pv.wcru3edh2ls.dlg@40tude.net> |
JJ wrote:
> On Tue, 10 May 2016 22:53:39 +0200, Tuxedo wrote:
> > Hello,
> >
> > If I have a window.onload event called from in a script or in the body
> > tag, for example:
> >
> > window.onload=alert('hello');
> > or
> > <body onload="alert('hello')">
> >
> > .... and after having navigated away from the page via for example a
> > link and if thereafter using the browser's back button, the onload event
> > will occur again when returning to the original page in FF and in other
> > browsers, but not in Safari for some reason - why not?
>
> The page is probably restored (not reloaded) from the browser's memory
> cache. A cache which include not just the web page resources, but also the
> DOM state. An optimized browser would restore a page from cache if
> possible, rather than simply reload it.
Thanks for clarifying this. It is indeed what happens with Safari and maybe
other browsers but not in FF and the Chrome browser.
> > I tested on an Ipad. Presumably Safari on a desktop OSX behaves the same
> > as on the Ipad. But Chrome, which is also utilising WebKit, behaves like
> > FF in this respect, so the difference appears to be Safari specific.
> >
> > Is it possible to detect if a page is returned to via the back button in
> > Safari?
>
> No. There's no event for browser's navigational actions except browser's
> own non standard events which are only accessible from with a browser
> extension.
The issue was that the user can modify elements on the page temporarily
which should not stay in their modified states after having left and
returned to the same page. To work around the different browsers I can
instead detect certain display states by inspecting various style elements
using for example setInterval and thereafter restore the wanted defaults
after the page was once unloaded and if the back button happens to
thereafter be used.
Tuxedo
Back to comp.lang.javascript | Previous | Next — Previous in thread | Find similar | Unroll thread
window.onload not working when using Safari's back button Tuxedo <tuxedo@mailinator.com> - 2016-05-10 22:53 +0200
Re: window.onload not working when using Safari's back button JJ <jj4public@vfemail.net> - 2016-05-11 14:01 +0700
Re: window.onload not working when using Safari's back button Tuxedo <tuxedo@mailinator.com> - 2016-05-11 21:39 +0200
csiph-web