16

I'm trying to use pageshow event on safari (iphone) to fix some problems with back button cache. But it seems to work only one time when using back button.

I have this handler on page A:

window.addEventListener("pageshow", function () {
    alert("pageshow");
});

Then i go to page B and go back to A - everything works fine. But when I go to page B again and go back to A again, then nothing happens.

example: go to this fiddle: https://jsfiddle.net/y278q8q0/, then navigate to any other page and play with back and forward buttons. The event will fire only once.

That how it looks on iphone 6 with ios 8.4: https://vid.me/5WPe

edit:

question was marked as a duplicate of this one: 'pageshow' is not received when pressing "back" button on Safari on *IPad"

It's hard to say if those problems have the same cause. In my case event always fires once at the beginning. Also I tried to implement all non-jquery solutions from mentioned question and none of them is working for me.

Community
  • 1
  • 1
Bodzio
  • 2,440
  • 2
  • 19
  • 37
  • Possible duplicate of ['pageshow' is not received when pressing "back" button on Safari on \*IPad"](http://stackoverflow.com/questions/10106457/pageshow-is-not-received-when-pressing-back-button-on-safari-on-ipad) – Michał Miszczyszyn Mar 07 '16 at 17:59
  • 1
    It might be a different issue, in my case the event is fired once, and then breaks. – Bodzio Mar 07 '16 at 18:06
  • It's basically the same thing. Have you tried the solution suggested here http://stackoverflow.com/a/10107335/704894 ? – Michał Miszczyszyn Mar 07 '16 at 22:48
  • Yes, tested all that didn't required jQuery (cause I don't have it in project). Tested on those jsfiddles: https://jsfiddle.net/y278q8q0/17/ https://jsfiddle.net/y278q8q0/18/ and the result is: https://vid.me/9HSs – Bodzio Mar 08 '16 at 09:37
  • I'm having the exact same problem, did you find anything? – Şafak Gür Mar 20 '17 at 22:01
  • I had exactly the same problem, but I narrowed it down quite a bit: the "pageshow" event fires only once in Safari 12 on OSX (didn't try iOS yet) IF you load the Facebook like button !! Doesn't matter if you load it via their JS SDK or iFrame solution, as soon as it appears on your page, the first time you hit the back button, an event triggers as expected. Go "Forward", then "backward" in your browser, no event at all !! Grrr FB – Bob Nov 16 '19 at 13:50

0 Answers0