背景:今天发现一个页面在我离开的时候和我看的时候title值不一样,就百度了一下原因
if (!document.hidden) {
console.log('页面激活');
}else{
console.log('页面非激活')
}
就是document有一个hidden属性,为true的时候页面为非激活状态,否则为激活状态,通过这个字段可以修改页面标题
背景:今天发现一个页面在我离开的时候和我看的时候title值不一样,就百度了一下原因
if (!document.hidden) {
console.log('页面激活');
}else{
console.log('页面非激活')
}
就是document有一个hidden属性,为true的时候页面为非激活状态,否则为激活状态,通过这个字段可以修改页面标题