检测全屏模式 [英] Detect fullscreen mode

查看:111
本文介绍了检测全屏模式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

现代桌面版的IE 10总是全屏的。

Modern desktop version of IE 10 is always fullscreen.

有一个:全屏 W3上的伪类

但是当我试图用jQuery版本1.9.x和2.x检测全屏时:

But when I tried to detect fullscreen with jQuery version 1.9.x and 2.x:

$(document).is(":fullscreen") 



it threw this error:


语法错误,无法识别的表达式:全屏

Syntax error, unrecognized expression: fullscreen





Questions:


  1. 是因为jQuery无法识别此标准还是IE10?

  1. Is it because jQuery doesn't recognize this standard yet or IE10?

检查全屏模式的旧版方式是什么?我期待以下结果:

What is the legacy way of checking fullscreen mode? I am expecting following results:

function IsFullScreen() {
     /* Retrun TRUE */
     /* If UA exists in classic desktop and not in full screen  */
     /* Else return FALSE */
}

li>

  • 我们可以在没有浏览器嗅探的情况下进行吗?

  • Can we do it without browser sniffing?


    推荐答案

    正如您所发现的,浏览器兼容性是一个很大的缺点。毕竟,这是一个非常新的东西。

    As you have discovered, browser compatibility is a big drawback. After all, this is something very new.

    然而,由于你使用JavaScript,你有更多的选择,如果你只是使用CSS。

    However, since you're working in JavaScript, you have far more options available to you than if you were just using CSS.

    例如:

    if( window.innerHeight == screen.height) {
        // browser is fullscreen
    }
    

    检查一些略微更松动的比较:

    You can also check for some slightly more loose comparisons:

    if( (screen.availHeight || screen.height-30) <= window.innerHeight) {
        // browser is almost certainly fullscreen
    }
    

    这篇关于检测全屏模式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

  • 查看全文
    登录 关闭
    扫码关注1秒登录
    发送“验证码”获取 | 15天全站免登陆