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

后端 未结 3 1114
长发绾君心
长发绾君心 2021-02-12 11:48

I\'ve seen some other posts about iOS 6\'s new behaviors with Web sites saved to / launched from the home screen. On iOS 5 (and earlier), we were able to use the Javascript Hist

相关标签:
3条回答
  • 2021-02-12 12:06

    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';

    0 讨论(0)
  • 2021-02-12 12:10

    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>
    
    0 讨论(0)
  • 2021-02-12 12:32

    Have your tried

    onclick="history.go(-1)"
    
    • This simple command should work.
    0 讨论(0)
提交回复
热议问题