js 浏览器窗口活跃监听

js 浏览器窗口活跃监听_第1张图片


<html lang="en">
<head>
	<meta charset="UTF-8">
	<title>Documenttitle>
head>
<body>
	<script>
		/*window.οnblur=()=>{
			document.title = '放入后台';
		}

		window.οnfοcus=()=>{
			document.title = '进入页面';
		}*/



		window.addEventListener('blur', ()=>{
      
			document.title = '放入后台';
		}, true);

		window.addEventListener('focus', ()=>{
      
			document.title = '进入页面';
		}, true);
	script>
body>
html>

你可能感兴趣的:(javascript,前端,浏览器窗口活跃监听,onblur,onfocus)