H5 监听返回页面的几种方法

535 阅读1分钟

页面返回后,需要监听和操作的几种方法

    var intersectionObserver = new IntersectionObserver(function(entries) {
    
        if (entries[0].intersectionRatio <= 0) return;

          intersectionObserver.observe(document.getElementById('changeReportUnread'));
  }
        window.onload = function () {
            console.log('---window.onload---')

        }
        window.onpageshow = function () {
            
        }
        document.addEventListener("pageshow", function () {
            window.alert('pageshow')
        });
        document.addEventListener("visibilitychange", function () {

        });
    原生监听关闭webview事件

    原生监听后台运行显示事件