1、浏览器切换事件 visibilitychange
document.addEventListener('visibilitychange', () => { if(document.visibilityState === "hidden") { document.title = "喂,你人呢?" } if(document.visibilityState === "visible") { document.title = "哎呀,你回来啦!" }
})
2、浏览器关闭事件 beforeunload
window.addEventListener('beforeunload',()=>{
console.log('啊?你要走了啊!')
})
3、浏览器刷新事件 onl oad
window.addEventListener('onload',()=>{ console.log('刷一刷!浪一浪!') })
标签:onload,浏览器,log,事件,addEventListener,document From: https://www.cnblogs.com/zha-hdlxdl/p/17617007.html