Is there a way to see that a browser window is minimized while the user is switching to the other window on iphone?

后端 未结 2 1435
孤城傲影
孤城傲影 2021-01-20 18:22

Is there a way to see that a browser window is minimized while the user is switching to the other window on IPhone? Same about when the browser window becom

2条回答
  •  无人及你
    2021-01-20 18:46

    I think the closest thing to what you're looking for are the pageshow and pagehide events. In tests I did in iOS 5.1, when switching to another application from Mobile Safari after double-pressing the home button, the pagehide event seemed to be fired immediately before the application actually switched, whereas if I pressed the home button just once to get to the home screen it seems the JavaScript thread is suspended immediately and listeners for the event are only called when Mobile Safari is brought into focus again.

    This is how you would listen for the events:

    window.addEventListener('pageshow', myPageShowListenerFunc, false);
    window.addEventListener('pagehide', myPageHideListenerFunc, false);
    

提交回复
热议问题