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.
> 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.