js当前网页失去焦点刷新页面 Gary Wang 2023-10-18 前端 js 浏览器失去焦点后重新获得 则刷新12345678// 浏览器失去焦点后重新获得 则刷新 document.addEventListener('visibilitychange', handleVisibilityChange); function handleVisibilityChange() { if (!document.hidden) { //刷新页面 window.location.reload() } } 改变浏览器宽度则刷新12345678//改变浏览器宽度则自动刷新let onloadPage window.onresize = function(){ window.clearTimeout(onloadPage) onloadPage = window.setTimeout(()=>{ window.location.reload() },2000)}