How can I change the web browser window state to Fullscreen in javascript(Like when user press F11)? I know how 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.
-
possible duplicate of [How to make in Javascript full screen windows (stretching all over the screen)](http://stackoverflow.com/questions/1125084/how-to-make-in-javascript-full-screen-windows-stretching-all-over-the-screen) – Oswald May 26 '11 at 10:16
-
Duplicate http://stackoverflow.com/questions/1125084/how-to-make-in-javascript-full-screen-windows-stretching-all-over-the-screen. – Ash Burlaczenko May 26 '11 at 10:16
-
1lol ,No , I told you **Current Window** – Saleh May 26 '11 at 10:18
-
And I told u like when user pressed F11 – Saleh May 26 '11 at 10:19
-
2Then it's a duplicate of [Could a website force the browser to go into fullscreen mode?](http://stackoverflow.com/questions/228377/could-a-website-force-the-browser-to-go-into-fullscreen-mode) :) – Frédéric Hamidi May 28 '11 at 10:26
-
1I have two monitors at home, and a blackberry in my pocket. Where's your fullscreen god now? – Incognito Jun 02 '11 at 20:03
-
1@Incognito: You have filled my cube with many laffs. – Jun 03 '11 at 21:55
5 Answers
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.

- 61,720
- 15
- 75
- 100
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.

- 2,385
- 1
- 19
- 29
-
1You're assuming F11 makes the browser full screen - it doesn't on my computer. :-) – RobG May 26 '11 at 11:38
-
It depends on the browser (might be another key) that is why we have the second check (the screen and window one). – Diogo Gomes May 26 '11 at 17:36
-
-
On Firefox the window.fullScreen boolean attribute tells you whether the user is in fullscreen mode. – Luc125 Jun 03 '11 at 14:44
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.

- 1,141
- 7
- 7
So far I know, it is only possible with security privileges, like in an intranet. For example:
The InternetExplorer.Application ActiveX objects have a "fullScreen" method.
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.

- 7,555
- 28
- 31