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);
}