检查浏览器是否全屏显示 [英] Checking if browser is in fullscreen
问题描述
可能重复:
检测浏览器是否处于全屏模式
有没有办法检查浏览器目前是否处于全屏模式(用户按下f11后)?
Is there a way to check if a browser is currently in fullscreen mode (after the user pressed f11)?
类似:
if (window.fullscreen) {
// it's fullscreen!
}
else {
// not fs!
}
谢谢。
Steerpike的答案非常好,但是我的评论:
Steerpike's answer is pretty good, but my comment:
非常感谢,但这个答案对于FF来说不是
。在Chrome中我可以设置
a小容差,但在FF中
urlbar和制表符需要一段时间才能
消失,这意味着在按
f11后,检测到的window.innerWidth是
仍然太小。
Thanks a lot, but this answer is not sufficient for FF. In Chrome I can set a small tolerance, but in FF the urlbar and tabs takes a while to disappear, which means after pressing f11, the detected window.innerWidth is still too small.
推荐答案
在Firefox 3中,window.fullScreen工作(< a href =https://developer.mozilla.org/en/DOM/window.fullScreen =noreferrer> https://developer.mozilla.org/en/DOM/window.fullScreen ) 。
In Firefox 3, window.fullScreen works (https://developer.mozilla.org/en/DOM/window.fullScreen).
所以,你可以这样做:
if((window.fullScreen) ||
(window.innerWidth == screen.width && window.innerHeight == screen.height)) {
} else {
}
这篇关于检查浏览器是否全屏显示的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!