如何启用Firefox和chrome等IE全屏功能 [英] How to enable IE full-screen feature like firefox and chrome

查看:125
本文介绍了如何启用Firefox和chrome等IE全屏功能的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我看了以下文章和jquery插件

I looked following articles and jquery plugins

http://www.sitepoint.com/html5-full-screen- api/

http://johndyer.name/native-fullscreen- javascript-api-plus-jquery-plugin/

http://xme.im/display-fullscreen-website-using-javascript

http://feross.org/html5-fullscreen-api-attack/

http://jquery.pupunzi.com/questions/696/ie-containerplus-全屏

IE Chrome框架全屏

但是找不到.

引用了所有这些主要文章,但是我找不到任何直接谈论IE全屏功能的文章, 有人找到解决方法吗?

All those major articles refereed, but I couldn't find any article which directly talking about IE full-screen feature, Any one found workaround to the same?

我尝试了W3C提案

// W3C Proposal
element.requestFullscreen();
document.exitFullscreen();

已更新 我的期望是,我有一个图像轮播,我需要显示当前选择的图像以全屏显示,似乎IE不支持,我打算使用jQuery模型窗口(不使用jQuery UI).就像示例.

UPDATED My expectation is, I have an image carousel, I need to show current selected image to show in full screen, seems to IE doesn't support, I plan to use jQuery model window(without jQuery UI). Just as the example.

推荐答案

sheelpriy答案很小,却很不错,已在chrome,firefox(即野生动物园和歌剧)(所有最新版本)上成功进行了测试

sheelpriy answer is good with a small change, successfully tested on chrome, firefox, ie, safari and opera (all last version)

//HTML Button : <a href="#" id="fullscreen">Fullscreen</a>

<script type="text/javascript">
    //Get element id "fullscreen"
    var fullScreenButton = document.getElementById("fullscreen"); 

    //Activate click listener
    fullScreenButton.addEventListener("click", function () {

        //Toggle fullscreen off, activate it
        if (!document.fullscreenElement && !document.mozFullScreenElement && !document.webkitFullscreenElement && !document.msFullscreenElement ) {
            if (document.documentElement.requestFullscreen) {
                document.documentElement.requestFullscreen();
            } else if (document.documentElement.mozRequestFullScreen) {
            document.documentElement.mozRequestFullScreen(); // Firefox
            } else if (document.documentElement.webkitRequestFullscreen) {
                document.documentElement.webkitRequestFullscreen(); // Chrome and Safari
            } else if (document.documentElement.msRequestFullscreen) {
                document.documentElement.msRequestFullscreen(); // IE
            }

        //Toggle fullscreen on, exit fullscreen
        } else {

            if (document.exitFullscreen) {
                document.exitFullscreen();
            } else if (document.msExitFullscreen) {
                document.msExitFullscreen();
            } else if (document.mozCancelFullScreen) {
                document.mozCancelFullScreen();
            } else if (document.webkitExitFullscreen) {
                document.webkitExitFullscreen();
            }
        }

    });
</script>

享受!

这篇关于如何启用Firefox和chrome等IE全屏功能的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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