我最终得到了以下解决方案:
function _fullscreenEnabled() {
// FF provides nice flag, maybe others will add support for this later on?
if(window['fullScreen'] !== undefined) {
return window.fullScreen;
}
// 5px height margin, just in case (needed by e.g. IE)
var heightMargin = 5;
if($.browser.webkit && /Apple Computer/.test(navigator.vendor)) {
// Safari in full screen mode shows the navigation bar,
// which is 40px
heightMargin = 42;
}
return screen.width == window.innerWidth &&
Math.abs(screen.height - window.innerHeight) < heightMargin;
}
它适用于我关心的每个浏览器(Chrome、FF、IE、Safari/Mac、Opera)。
更新:它不适用于 Opera/Mac,Mac 上的 Opera 在全屏模式下仅隐藏“通用”OSX 菜单,因此高度仅相差几个像素,这对我来说太危险了。