如何通过JavaScript使用F11的按键事件,使浏览器全屏 [英] How to make browser full screen using F11 key event through JavaScript

查看:1923
本文介绍了如何通过JavaScript使用F11的按键事件,使浏览器全屏的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想让我的浏览器全屏。同样,当我们做F11关键事件。我发现了一些例子,如

I want to make my browser full screen. Same as when we do F11 key event. I found some examples such as

function maxwin() {
    var wscript = new ActiveXObject("WScript.Shell");
    if (wscript!=null) {
         wscript.SendKeys("{F11}");
    }
}

这并不在Mozilla或其他任何最新的浏览器。请让我知道如果有什么办法来解决这个问题。

Which does not work on mozilla or any other latest browsers. Please let me know if there is any way to sort out this problem.

感谢。 (事先)。

推荐答案

使用code,而不是

var el = document.documentElement
, rfs = // for newer Webkit and Firefox
       el.requestFullScreen
    || el.webkitRequestFullScreen
    || el.mozRequestFullScreen
    || el.msRequestFullScreen
;
if(typeof rfs!="undefined" && rfs){
  rfs.call(el);
} else if(typeof window.ActiveXObject!="undefined"){
  // for Internet Explorer
  var wscript = new ActiveXObject("WScript.Shell");
  if (wscript!=null) {
     wscript.SendKeys("{F11}");
  }
}

来源:<一个href=\"http://stackoverflow.com/questions/1125084/how-to-make-in-javascript-full-screen-windows-stretching-all-over-the-screen\">How在Javascript全屏窗口,使(拉伸全屏幕)

工程和在Chrome,FF10以上,高于IE 8,Safari 5的测试..

Works and tested on Chrome, FF10 above, IE 8 above, Safari 5..

这篇关于如何通过JavaScript使用F11的按键事件,使浏览器全屏的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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