Background behavior for iOS Web App (so app doesn't restart)

你。 提交于 2019-12-04 14:02:17

问题


I'm trying to build a mobile web app and am intrigued by the "apple-mobile-web-app-capable" option, making the app feel a lot more native.

The issue I'm having is that it's an app that lets a user browse through a bunch of content, some of which opens a new browser window outside the web app (on purpose). The problem is, when a user goes back to the web app, it re-launches and starts them from the home page.

Has anyone found a way to avoid this complete reloading process?


回答1:


ive got it working like this:

if(window.navigator.standalone === true) {
    var lastpage = localStorage.getItem('exitsatus');
    if (lastpage==null){
        lastpage = "index.html";
    }
    if(document.referrer.length > 0 && document.referrer.indexOf("mysite.com") != -1){
        var lastpageupdate = window.location;
        localStorage.setItem('exitsatus',lastpageupdate);      
    } else {
        window.location = lastpage;
    }
}



回答2:


There is, but it's a bit of a hack and requires some JavaScript.

What you want to do is at the end of each page load, save the current path in offline key-value storage. In your head, see if there's an entry for the URL and if so, load it up. What you want to ensure is that internal links disable this key so that you don't just jump to a link and then back again.




回答3:


SO from what I gathered from other people outside SO, this just isn't possible.



来源:https://stackoverflow.com/questions/5810648/background-behavior-for-ios-web-app-so-app-doesnt-restart

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