How to detect browser support for pageShow and pageHide?

后端 未结 1 844
一整个雨季
一整个雨季 2021-02-04 14:32

How can we do JavaScript object detection for pageShow and pageHide handlers?

if( /* pagehide is supported */ ){
   window.addEventListener(\'pagehide\', exitFun         


        
相关标签:
1条回答
  • 2021-02-04 14:51
    if ('onpagehide' in window) {
    //if(window.onpagehide || window.onpagehide === null){
       window.addEventListener('pagehide', exitFunction, false);
    } else {
       window.addEventListener('unload', exitFunction, false);
    }
    
    0 讨论(0)
提交回复
热议问题