This question already has answers here:
Closed 2 years ago.
So I'm trying to redirect the user back one level in the history on an iPhone HomeScreen App, but it's simply just not firing for some reason.
Current code is as follows window.history.go(-1)
I've also tried various other version window.history.back()
, history.go(-1)
, but no luck yet. I can't wrap my head around how to implement the pushState, so I haven't tried that approach yet, but it's quite annoying how incredibly bad the homescreen app stuff is made.
Atleast you're able to debug with Safari.
You can debug mobile safari, but unfortunately you need a mac.
If not, try this:
- Make sure your code is working and no errors on desktop safari;
- Check if you are actually making the call by adding an
alert("history() called")
in place of the history(-1)
code;
- Is it in a link that has a default behavour to navigate to another page? If so, you need a
event.preventDefault()
or at least a return false;
after the history() call.
Try something like:
<a href="javascript:history.go(-1)">Go back</a>