jQuery判断当前页面是否被浏览

<!DOCTYPE html>
<html>

<head>
    <meta charset="utf-8">
    <title>jQuery判断当前页面是否被浏览</title>
</head>

<body>
    <script src="https://cdn.bootcss.com/jquery/3.3.1/jquery.min.js"></script>
    <script>
    $(document).on('visibilitychange', function(e) {
        if (e.target.visibilityState === "visible") {
            document.title = '被发现啦!';
        } else if (e.target.visibilityState === "hidden") {
            document.title = '藏好啦!';
        }
    });
    </script>
</body>

</html>

 

相关文章:

  • 2022-12-23
  • 2021-05-21
  • 2022-12-23
  • 2022-01-11
  • 2021-08-29
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-02-07
  • 2022-12-23
  • 2021-11-30
  • 2022-12-23
相关资源
相似解决方案