Hy all, I need a javascript code, that when my site loads, automatically load it into full screen mode, as if i was pressing F11, and i have my reasons to do that..So anyone knows the right code to do that? I also need to prevent the user from changing the screen size of the page
-
try google? first result in google search http://www.frihost.com/forums/vt-118683.html with keywords `javascript f11 full screen` – QQping Mar 19 '12 at 13:59
-
2If I were to make a sweeping generalisation, I might say that if someone feels the need to say *"i have my reasons to do that"* but not share what those reasons are, then they are probably very poor reasons. – Quentin Mar 19 '12 at 14:03
-
duplicate to http://stackoverflow.com/q/9688995/1048572 – Bergi Mar 19 '12 at 14:20
-
I tried the one posted in stackoverflow.com/q/9688995/1048572 and it didn't work – ELias Rahme Mar 19 '12 at 14:22
-
so what you are requesting is taking control of a persons browser and not letting them re size the window at all? I don't think you will find anything like that cross browser, I know I personally would disable such a thing with any browser I had. – Jakub Mar 19 '12 at 14:27
-
https://stackoverflow.com/a/28589187/3212513 - This will work – Dhiraj Jan 04 '18 at 15:31
2 Answers
There is a full screen API, but it is currently an early draft and browser support is very weak.
Foisting full screen mode on anyone who visits your site is one of the more hostile things you can do as a web author. You should seek an alternative design that solves whatever problem you have without doing that.

- 914,110
- 126
- 1,211
- 1,335
-
I am not working on a website, i'm working on a web application based on HTML5 for a very small targeted audience and the full screen option is going to surve me with my application. I'm not oriented towards online websites – ELias Rahme Mar 19 '12 at 14:19
Unfortunately, there is no perfect way to get the browser to come up in full screen mode. However, you can use the screen object to determine the screen size, and set your window size appropiately. The useful screen properties are availWidth and availHeight or width and height. You can then use those to set the window object properties, either innerWidth and innerHeight or outerWidth and outerHeight. I suggest you play around with retrieving and setting these properties. Also, different browsers behave slightly differently, so, if possible, I suggest you try your code on IE (which (surprise!) is the least standard), Firefox, Safari, and Chrome.
I know the "purists" will tell you forcing a certain window size is not a good thing to do. But in some cases it is appropriate. I have written an application related to the card game bridge, and, if the browser comes up too small, the card images are unreadable. So, the first time a user accessses my web page, I make it as large as I can. Most people leave it that size. But, if they reduce the size, I store the dimensions in a cookie, and the next time they go to my page, it remembers how big to make the page. I have received many compliments on using this approach.

- 2,115
- 1
- 15
- 8