Click here to Skip to main content
15,868,016 members
Articles / Programming Languages / Javascript
Article

Javascript - mimic browser Fullscreen

Rate me:
Please Sign up or sign in to vote.
0.00/5 (No votes)
11 Oct 2013CPOL1 min read 6.8K   1  
In this article we are going to see how to have the browser resemble a fullescreen - through javascript. Usually it is not possible to trigger the

This articles was originally at wiki.asp.net but has now been given a new home on CodeProject. Editing rights for this article has been set at Bronze or above, so please go in and edit and update this article to keep it fresh and relevant.

In this article we are going to see how to have the browser resemble a fullescreen - through javascript. Usually it is not possible to trigger the fullscreen(F11) through javascript as it is a security issue. But we can have the statusbar, toolbar, addressbar, title bar of the browser hidden to resemble the fullscreen.

Let us take this scenario of setting the browser to fullscreen on click of a button.

1. We can open the current url in a new window using window.open method of javascript

window.open(URL,name,features,replace);

2.The features can now be configured by using the available items.

params = 'width=' + screen.availWidth;  

params += ', height=' + screen.availHeight;

params += ', fullscreen=yes';

params += ', status=no,titlebar=no,location=0,top=0, left=0';

window.open(window.location, "fullscreentest", params);

The below link has the list of all available parameter and the values.

http://www.w3schools.com/jsref/met_win_open.asp

3. When this is done on a click of a button, we will be able to see the browser in fullscreen mode.

The complete code snippet is given below.

CodeSnippet

function fullscreen() {   

            params = 'width=' + screen.availWidth;

            params += ', height=' + screen.availHeight; 

            params += ', fullscreen=yes';

            params += ', status=no,titlebar=no,location=0,top=0, left=0';           

            window.open(window.location, "test", params);

        }

 

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
United States United States
The ASP.NET Wiki was started by Scott Hanselman in February of 2008. The idea is that folks spend a lot of time trolling the blogs, googlinglive-searching for answers to common "How To" questions. There's piles of fantastic community-created and MSFT-created content out there, but if it's not found by a search engine and the right combination of keywords, it's often lost.

The ASP.NET Wiki articles moved to CodeProject in October 2013 and will live on, loved, protected and updated by the community.
This is a Collaborative Group

755 members

Comments and Discussions

 
-- There are no messages in this forum --