开发者

Change Window State to Fullscreen

How can I change the web browser window state to Fullscreen in javascript(Like when user press F11)? I know h开发者_运维百科ow can I specify Window State of new Window that has been opened by Window.Open Method but I want to change the sate of current Window.


You can't and you shouldn't do this.

  • You shouldn't do this, because it is a annoying user experience. So let the user decide and maybe ask him to press the button for fullscreen mode, but never force him.
  • You can't because the browser vendors disabled this feature for the reasons of my last point.

Minimal workarround would be to set the window size of the new window to something close to the screen resolution, but this could be tricky if the user has a dual screen.


You can't.

Just ask for the user to press to press F11 and then detect if the user pressed it by checking the key code 122 (eg: keyup event) and comparing the size of the window with the size of the screen (screen.width/height and window.innerWidth/Height).

It's not perfect, specially for users with multiple screens.


You can open a window without toolbars with JS:

window.open("http://www.stackoverflow.com","mywindow","menubar=0,resizable=1,toolbar=0,status=0,width=5000,height=5000");

It will probably be blocked by popup blockers, but that is the most you can do.


So far I know, it is only possible with security privileges, like in an intranet. For example:

  1. The InternetExplorer.Application ActiveX objects have a "fullScreen" method.

  2. In Firefox 3+, if you have Chrome-privileges you can use "window.fullScreen = true;" but without those privileges this property is read-only ( https://developer.mozilla.org/en/DOM:window.fullScreen ).


Easy.

<strong>Please view in fullscreen (F11 on most browsers).</strong>
<a href="javascript:showExplanation()">Here's why</a>

No, there's no cheat to remove control of a browser from the user.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜