Javascript 检测覆盖iframe的系统窗口
在看了之后,我很好奇所显示的一些特性是如何用JS实现的 我的一个主要问题是如何在iframe上检测另一个系统窗口(如视频中显示的单词窗口) 在上,有一个提示表明该技术基于浏览器优化视图外元素的渲染这一事实 我无法了解所使用的确切方法/属性Javascript 检测覆盖iframe的系统窗口,javascript,html,iframe,optimization,render,Javascript,Html,Iframe,Optimization,Render,在看了之后,我很好奇所显示的一些特性是如何用JS实现的 我的一个主要问题是如何在iframe上检测另一个系统窗口(如视频中显示的单词窗口) 在上,有一个提示表明该技术基于浏览器优化视图外元素的渲染这一事实 我无法了解所使用的确切方法/属性 你的想法是什么 据我所知,可以检测页面是在前台还是在后台,或者更准确地说,是有焦点还是没有焦点 var focus=true; window.onblur=function(){focus=false;action();} window.onfocus=fu
你的想法是什么 据我所知,可以检测页面是在前台还是在后台,或者更准确地说,是有焦点还是没有焦点
var focus=true;
window.onblur=function(){focus=false;action();}
window.onfocus=function(){focus=true;action();}
document.onblur=window.onblur;
document.focus=window.focus;
函数动作(){
如果(焦点){
document.body.style.background=“绿色”;
}否则{
document.body.style.background=“浅灰色”;
}
}
尝试单击内部然后单击外部
您必须检查文档。焦点
以及窗口和屏幕监视器的位置/大小
也许是这样:
您可以在此处尝试我的演示:
let bool=document.hasFocus();
$(“p.info”)。文本(“in”);
console.log(外径+屏幕X)
if(screen.width
也:
- 您可以比较两个设置间隔之间的时间
,以检测非活动浏览器李>(+new Date())
let bool = document.hasFocus();
$("p.info").text("in");
console.log(outerWidth + screenX)
if (screen.width < outerWidth + screenX) {
bool = false;
$("p.info").text("right side: out");
} else if ((outerWidth - innerWidth) + screenX < 0) {
bool = false;
$("p.info").text("left side: out");
} else if (screen.height < outerHeight + screenY) {
bool = false;
$("p.info").text("bottom side: out");
} else if ((outerHeight - innerHeight) + screenY < 0) {
bool = false;
$("p.info").text("top side: out");
}
if (currentChild && !currentChild.closed) {
let rectPage = {
left: (outerWidth - innerWidth) + screenX,
top: (outerHeight - innerHeight) + screenY,
right: outerWidth + screenX,
bottom: outerHeight + screenY
};
let rectPopup = {
left: currentChild.screenX,
top: currentChild.screenY,
right: currentChild.outerWidth + currentChild.screenX,
bottom: currentChild.outerHeight + currentChild.screenY
};
if (intersectRect(rectPage, rectPopup)) {
$("p.info").text("eclipse with popup");
bool = false;
}
}
$page.text(pin(bool));