【发布时间】:2014-06-23 19:09:57
【问题描述】:
我有一个 Chrome 扩展程序,可以在页面中插入一个菜单,但是每当任何 flash 或 html5 视频播放器全屏显示时,视频播放器之外的任何内容都是不可见的。
我可以同时全屏显示两个对象(一个在另一个上),还是有其他方法可以做到这一点?由于现有的视频播放器种类繁多,我宁愿不必将 html 专门插入不同网站的不同位置。该解决方案应该适用于所有视频播放器。
编辑:
从那时起,很多网络都开始使用 html5 而不是 flash,所以这已成为几乎所有网站都可以做的事情。
这是我最终编写和使用的代码。希望这会对某人有所帮助:
document.addEventListener("webkitfullscreenchange", function(){//Whenever an element becomes or stops being in full screen
//first, grab the page's fullscreenElement
var fse = document.fullscreenElement||document.mozFullScreenElement||document.webkitFullscreenElement||document.msFullscreenElement;
if(fse){//if there is a fullscreened element
fse.appendChild(menu);//append the menu inside the fullscreened element
}else{//if nothing is in full screen
if(window.self !== window.top){//if we are in an iframe
menu.remove();//hide menu if we are in an iframe
}else{//if we arn't in an iframe
document.body.insertBefore(menu, document.body.firstChild);//show menu
}
}
});
【问题讨论】:
-
如果你能得到屏幕截图会很有帮助,这样我们就可以了解出了什么问题。
-
你说的div,可能跟z-index这个属性有关?
-
div有什么
position和display? -
style="z-index: 9999998; background-color: rgb(153, 102, 0);position: fixed;"
-
您可以全屏显示除视频元素之外的元素,它会显示您正在寻找的内容。例如,使用 mediabrowser3 全屏视频播放器,我还可以将视频控件显示为悬停时的叠加层。但是,您似乎正在尝试在 Youtube 上覆盖某些内容,是的,这可能行不通。如果您无法控制 如何 全屏是实现的,那么您将被给定的内容所困扰。示例:Imgur
标签: javascript jquery html css google-chrome