[英]how can I detect changes in document.hidden with javascript/jquery?
I want to run some code when document.hidden
is changed from false
to true
. 当document.hidden
从false
更改为true
时,我想运行一些代码。
How can I do it? 我该怎么做?
You should use the visibilitychange
event. 您应该使用visibilitychange
事件。 See the MDN documentation for more information. 有关更多信息,请参见MDN文档 。
document.addEventListener("visibilitychange", function() { console.log(document.visibilityState); console.log(document.hidden); });
You should use the visibilitychange event: 您应该使用能见度更改事件:
document.addEventListener("visibilitychange", function() {
console.log( document.visibilityState );
});
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.