Click here to Skip to main content
65,938 articles
CodeProject is changing. Read more.
Articles
(untagged)

Javascript - mimic browser Fullscreen

0.00/5 (No votes)
29 Dec 2010 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 has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here