网站能否强制浏览器进入全屏模式? [英] Could a website force the browser to go into fullscreen mode?

查看:36
本文介绍了网站能否强制浏览器进入全屏模式?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想进行一项心理学研究,参与者必须查看大图像.

I want to run a psychological study for which participants have to look at large images.

该实验是在网络上完成的,因此是在浏览器窗口中完成的.是否可以让浏览器进入全屏模式,例如按下按钮?

The experiment is done on the web and therefore in a browser window. Is it possible to tell the browser to go into fullscreen, for example on button press?

我知道可以打开固定大小的弹出窗口.你认为这是一个可行的选择吗?如果,最好的方法是什么?是否有检测弹出窗口阻止程序、回退并在原始浏览器窗口中运行研究的优雅方法.

I know there is the possibility to open a fixed-size popup window. Do you think this would be a feasable alternative? And if, what would be the best way to do it? Are there elegant ways of detecting a popup-blocker, to fallback and run the study in the original browser window.

主要关注点是本研究的参与者不熟悉技术细节,不应被他们打扰.

The main concern is that the participants of this study are not familiar with technical details and should not be bothered by them.

推荐答案

我搜索了一些代码.

function fullscreen() {
    var element = document.getElementById("content");
    if (element.requestFullScreen) {
        if (!document.fullScreen) {
            element.requestFullscreen();
            $(".fullscreen").attr('src',"img/icons/panel_resize_actual.png");
        } else {
            document.exitFullScreen();
            $(".fullscreen").attr('src',"img/icons/panel_resize.png");
        }

    } else if (element.mozRequestFullScreen) {

        if (!document.mozFullScreen) {
            element.mozRequestFullScreen();
            $(".fullscreen").attr('src',"img/icons/panel_resize_actual.png");
            google.maps.event.trigger(map, 'resize');
        } else {
            document.mozCancelFullScreen();
            $(".fullscreen").attr('src',"img/icons/panel_resize.png");
        }

    } else if (element.webkitRequestFullScreen) {

        if (!document.webkitIsFullScreen) {
            element.webkitRequestFullScreen();
            $(".fullscreen").attr('src',"img/icons/panel_resize_actual.png");
            google.maps.event.trigger(map, 'resize');
        } else {
            document.webkitCancelFullScreen();
            $(".fullscreen").attr('src',"img/icons/panel_resize.png");
        } 
    } 
}

它将使用 html5 api.我用 jquery 为它切换了一张特殊的图片.希望这会有所帮助.目前,我不知道你是否可以强制执行它,因为它已被安全禁止.

It will use html5 api. I switch with jquery the a special picture for it. Hope that will help out. At the moment, i don't know if you can force it, 'cause it was forbitten due security.

这篇关于网站能否强制浏览器进入全屏模式?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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