What event fires when a WebKit WebApp is “terminated”

后端 未结 2 1470
走了就别回头了
走了就别回头了 2020-12-11 09:28

I am in the process of developing a Web App for iOS and am using the DOMApplicationCache. I know that Web Apps can not run in the background, but I still would like to simul

相关标签:
2条回答
  • 2020-12-11 09:57

    You can use the "pageshow" event to detect when the app has resumed. This event will fire when user returns to your app from a different safari tab. It will also fire when user clicks the home button and then comes back to the app by clicking on safari button

         <script>
        window.addEventListener("pageshow", function(){
            alert("page shown");
        }, false);
      </script>
    

    I have tested this on the iOS simulator and its working as I described above.

    0 讨论(0)
  • 2020-12-11 10:14

    I have an answer. It's not what we were hoping for.

    The technical definition of unload from http://www.w3.org/TR/DOM-Level-2-Events/events.html is:

    The unload event occurs when the DOM implementation removes a document from a window or frame. This event is valid for BODY and FRAMESET elements.

    I also got a reply from some in the know at Apple: "Unfortunately, I haven't been able to find an event that fires when the Home button is clicked! I think the most appropriate event for this might be the pagehide event. This event actually does fire in Safari on iOS when you switch to the "tabs" view to open a new page, but not when you click the home screen icon :-("

    0 讨论(0)
提交回复
热议问题