Categories

Tags

浏览器标签tab窗口切换时事件状态侦听

<script>
document.addEventListener('visibilitychange',function(){ //浏览器切换事件
    if(document.visibilityState=='hidden') { //状态判断
        document.title = '标题二';
    }else {
        document.title = '标题一';
    }
});
</script>