Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

window.history.go(-1) not working in iOS HomeScreen App [duplicate]

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.

like image 940
Nict Avatar asked Feb 07 '14 10:02

Nict


2 Answers

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

If not, try this:

  1. Make sure your code is working and no errors on desktop safari;
  2. Check if you are actually making the call by adding an alert("history() called") in place of the history(-1) code;
  3. 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.

iOS simulator safari debugger

like image 152
Chris Gunawardena Avatar answered Sep 17 '22 08:09

Chris Gunawardena


Try something like:

<a href="javascript:history.go(-1)">Go back</a>
like image 37
ayunami2000 Avatar answered Sep 20 '22 08:09

ayunami2000