页面超过 10 分钟没有任何操作
页面超过 10 分钟没有任何操作
<!DOCTYPE html>
<html lang="zh-Hans">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<meta name="author" content="xgqfrms">
<meta name="generator" content="VS code">
<title>all web page events all in one</title>
<style>
pre#app {
color: #0f0;
background: #000;
padding: 30px;
}
</style>
</head>
<body>
<header>
<h1>test</h1>
</header>
<main>
<section>
<pre id="app"></pre>
</section>
<article></article>
<main>
<footer>
<p>copyriht© xgqfrms 2021</p>
</footer>
<script src="./userEventsCheeker.js"></script>
<script>
// load
const app = document.querySelector(`#app`);
let timerId = null;
// 1000 * 60 * 10
const callback = (obj = {}, timer = 1000 * 60) => {
console.log('keydown e', JSON.stringify(obj, null, 4));
if([Object.keys(obj)].length) {
app.innerHTML = JSON.stringify(obj, null, 4);
if(timerId) {
clearTimeout(timerId);
}
}
// localStorage Map pathname ? false : true
timerId = setTimeout(() => {
console.log('该页面超过 1 分钟没有任何操作了');
alert('该页面超过 1 分钟没有任何操作了');
}, timer);
}
const test = new UserEventsChecker('app', callback);
// test();
</script>
</body>
</html>
refs
©xgqfrms 2012-2020
www.cnblogs.com 发布文章使用:只允许注册用户才可以访问!
原创文章,版权所有©️xgqfrms, 禁止转载 🈲️,侵权必究⚠️!
本文首发于博客园,作者:xgqfrms,原文链接:https://www.cnblogs.com/xgqfrms/p/14591586.html
未经授权禁止转载,违者必究!