This is now possible in the latest versions of Chrome, Firefox and IE(11).
(现在可以在最新版本的Chrome,Firefox和IE(11)中实现。)
Following the pointers by Zuul on this thread , I edited his code to include IE11 and the option to full screen any element of choice on your page.
(按照Zuul在该线程上的指针,我编辑了他的代码,以包括IE11和全屏显示您页面上所选元素的选项。)
JS:
(JS:)
function toggleFullScreen(elem) {
// ## The below if statement seems to work better ## if ((document.fullScreenElement && document.fullScreenElement !== null) || (document.msfullscreenElement && document.msfullscreenElement !== null) || (!document.mozFullScreen && !document.webkitIsFullScreen)) {
if ((document.fullScreenElement !== undefined && document.fullScreenElement === null) || (document.msFullscreenElement !== undefined && document.msFullscreenElement === null) || (document.mozFullScreen !== undefined && !document.mozFullScreen) || (document.webkitIsFullScreen !== undefined && !document.webkitIsFullScreen)) {
if (elem.requestFullScreen) {
elem.requestFullScreen();
} else if (elem.mozRequestFullScreen) {
elem.mozRequestFullScreen();
} else if (elem.webkitRequestFullScreen) {
elem.webkitRequestFullScreen(Element.ALLOW_KEYBOARD_INPUT);
} else if (elem.msRequestFullscreen) {
elem.msRequestFullscreen();
}
} else {
if (document.cancelFullScreen) {
document.cancelFullScreen();
} else if (document.mozCancelFullScreen) {
document.mozCancelFullScreen();
} else if (document.webkitCancelFullScreen) {
document.webkitCancelFullScreen();
} else if (document.msExitFullscreen) {
document.msExitFullscreen();
}
}
}
HTML:
(HTML:)
<input type="button" value="click to toggle fullscreen" onclick="toggleFullScreen(document.body)">
Where "document.body" is any element you so wish.
(其中“ document.body”是您希望的任何元素。)
Also note that trying to run these full screen commands from the console do not appear to work on Chrome or IE.
(另请注意,尝试从控制台运行这些全屏命令似乎不适用于Chrome或IE。)
I did have success with Firebug in Firefox though. (我在Firefox中使用Firebug确实取得了成功。)
One other thing to note is that these "full screen" commands don't have a vertical scrollbar, you need to specify this within the CSS:
(要注意的另一件事是这些“全屏”命令没有垂直滚动条,您需要在CSS中指定此滚动条:)
*:fullscreen
*:-ms-fullscreen,
*:-webkit-full-screen,
*:-moz-full-screen {
overflow: auto !important;
}
The "!important" seems to be necessary for IE to render it
(“!重要”似乎是IE渲染它所必需的)
Here's an example of it working .
(这是它工作的一个例子 。)
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…