Javascript history function not working for web page served from homescreen on iOS 6

对着背影说爱祢 提交于 2019-12-03 09:48:05

My understanding is that if you add the apple-mobile-web-app-capable tag - it caches the page that is bookmarked to the home screen.

Any subsequent requests once the bookmark is launched will cause the safari browser to launch the url (with ugly chrome added).

You could do some basic error checking - if there is any history:

function GoBack() {
   if(history.length) {
       history.back();
       return false;
   }
   return true; //follow the regular link
}

And you really should be giving your urls a proper href value instead:

<a href="http://your_standard_url" class="back" onClick="GoBack()"></a>

Have your tried

onclick="history.go(-1)"
  • This simple command should work.

Try one of them

window.history.pushState

http://thelink.is/history-api-ios-bug

OR

window.history.pushState(data, title, 'a/new/url#');

OR

window.history.pushState(data, title, 'a/new/url');

window.location.hash = 'new';

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!