当前位置:网站首页>Browser window switch activation event visibilitychange
Browser window switch activation event visibilitychange
2022-06-30 19:17:00 【AdleyTales】
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<style>
</style>
</head>
<body>
<h1> Browser window switch activation event </h1>
<div id="app"></div>
<script>
/**
* visibilitychange: When browser visibility changes , This event will be triggered
*
* We can do it in document Object visibilitychange event ,
* according to document.hidden perhaps document.visibilityState Attributes do some business logic .
*
* Example scenario
* Client embedded H5 A scenario often encountered on a page :H5 Page has a video , While it's playing , Click other buttons on the page ,
* Enter the client native page , Or open a new webview, The video should be paused , When returning to this page , The video continues to play .
*
*/
document.addEventListener('visibilitychange', (ev) => {
// console.log(ev);
console.log(document.hidden, document.visibilityState) // visible hidden
console.log('----active window ------')
if(!document.hidden) {
doSomething()
}
}, false)
function doSomething() {
console.log('do some thing ...')
}
</script>
</body>
</html>
effect

边栏推荐
- PC端微信多开
- How to use AI technology to optimize the independent station customer service system? Listen to the experts!
- 基于 actix、async-graphql、rbatis、pgsql/mysql 构建 GraphQL 服务(4)-变更服务
- Lenovo Yoga 27 2022, full upgrade of super configuration
- nats集群部署
- 3.10 haas506 2.0 development tutorial example TFT
- Courage to be hated: Adler's philosophy class: the father of self inspiration
- Build graphql service based on Actix, async graphql, rbatis, pgsql/mysql (4) - change service
- Neon optimization 2: arm optimization high frequency Instruction Summary
- Kalman滤波器--从高斯融合推导
猜你喜欢

链表中环的入口结点-链表专题

Brief introduction of Feature Engineering in machine learning

TCP粘包问题

20220607跌破建议零售价,GPU市场正全面走向供过于求...

Four tips tell you how to use SMS to promote business sales?

Dlib库实现人脸关键点检测(Opencv实现)

浏览器窗口切换激活事件 visibilitychange

Nodejs 安装与介绍

Personally test the size of flutter after packaging APK, quite satisfied

正则表达式(正则匹配)
随机推荐
ArcGIS无插件加载(无偏移)天地图
充值满赠,IM+RTC+X 全通信服务「回馈季」开启
[Collection - industry solutions] how to build a high-performance data acceleration and data editing platform
详解单例模式
领导:谁再用 Redis 过期监听实现关闭订单,立马滚蛋!
云上“视界” 创新无限 | 2022阿里云直播峰会正式上线
Business Intelligence BI and business management decision-making thinking 4: business cost analysis
opencv数据类型代码表 dtype
年复一年,为什么打破数据孤岛还是企业发展的首要任务
Is it safe to open an account for goucai? Is it reliable?
torch. roll
视频内容生产与消费创新
PC端微信多开
Tensorflow2 ten must know for deep learning
基于 actix、async-graphql、rbatis、pgsql/mysql 构建 GraphQL 服务(4)-变更服务
音频 librosa 库 与 torchaudio 库中 的 Mel- spectrogram 进行对比
mysql函数获取全路径
Video content production and consumption innovation
商业智能BI与业务管理决策思维之四:业务成本分析
Dlib library for face key point detection (openCV Implementation)