How to make the window full screen with Javascript (stretching all over the screen)

In newer browsers such as Chrome 15, Firefox 10, Safari 5.1, IE 10 this is possible. It’s also possible for older IE’s via ActiveX depending on their browser settings.

Here’s how to do it:

function requestFullScreen(element) {
    // Supports most browsers and their versions.
    var requestMethod = element.requestFullScreen || element.webkitRequestFullScreen || element.mozRequestFullScreen || element.msRequestFullScreen;

    if (requestMethod) { // Native full screen.;
    } else if (typeof window.ActiveXObject !== "undefined") { // Older IE.
        var wscript = new ActiveXObject("WScript.Shell");
        if (wscript !== null) {

var elem = document.body; // Make the body go full screen.

The user obviously needs to accept the fullscreen request first, and there is not possible to trigger this automatically on pageload, it needs to be triggered by a user (eg. a button)

Read more:

Leave a Comment