Window.history.go (-1) does not work in iOS HomeScreen application

So, I'm trying to redirect the user one level in the history of the iPhone HomeScreen application, but for some reason he just doesn’t shoot.

The current code is as follows window.history.go(-1)

I also tried another version of window.history.back() , history.go(-1) , but so far no luck. I can't get my head on how to implement pushState, so I haven't tried this approach yet, but it's pretty annoying how the desktop app works incredibly poorly.

At least you can debug using Safari.

+8
javascript jquery ios web-applications
source share
2 answers

You can debug a mobile safari, but unfortunately you need a Mac.

If not, try the following:

  • Make sure your code works, and no errors on the desktop safari;
  • Verify that you are actually making the call by adding alert("history() called") instead of the history(-1) code;
  • Is this a link that has default behavior to go to another page? If so, you will need event.preventDefault() or at least a return false; after calling history ().

iOS simulator safari debugger

+5
source share

Try something like:

 <a href="javascript:history.go(-1)">Go back</a> 
+1
source share

All Articles