Run a website in fullscreen mode

I am looking for a trick to put my website in fullscreen mode without human interaction.

I've found some examples using HTML5's techniques, but all of then needs to be triggered by a human interaction.

This website will be displayed in a TV ...

I already think in load the website using a SWF file in fullscreen mode, but instead of going to this direction, I would like to stress all possibilities using just the default pattern (html, css and javascript)


Solution 1:

You can't force a website to display in fullscreen mode.

Imagine the security concerns if that were possible.
Malicious websites could "Hijack" a less computer literate person's desktop for all kinds of dubious business.

All of JS fullscreen api's will throw a error like this:
"Failed to execute 'requestFullScreen' on 'Element': API can only be initiated by a user gesture." If you try to simply call it from your code.

I'm pretty darn sure Flash is similar, in that it requires user interaction to go fullscreen. Otherwise, we'd have seen our fair share of fullscreen popups that are nearly impossible to close.

Solution 2:

Other answers already describe how you can go fullscreen in a more or less browser-independent way. However, problem of needing user interaction remains.


You cannot force your webpage to display in fullscreen mode for security reasons. User interaction is required for that.

Also, browser leaves fullscreen mode whenever user goes to another page, even on the same website, and (s)he will have to perform some "user interaction" on every page to go back into fullscreen mode.
This is the reason why your website has to be a single page if you want it to be fullscreen.


That is what I suggest: Use a single splash page that has a hidden iFrame on it.

Whenever user clicks anywhere or presses any key, just set this iFrame to be fullscreen and show it. When you receive an event on leaving fullscreen mode, hide iFrame again to show splash.

Links open in the same frame by default, so you will stay in fullscreen mode until user explicitly leaves it or some links opens in a new tab.

Here is an example that works in Chrome:
(See it in action. Use other answers to make it browser-independent.)

<html>
<head>
    <script language="jscript">
        function goFullscreen() {
            // Must be called as a result of user interaction to work
            mf = document.getElementById("main_frame");
            mf.webkitRequestFullscreen();
            mf.style.display="";
        }
        function fullscreenChanged() {
            if (document.webkitFullscreenElement == null) {
                mf = document.getElementById("main_frame");
                mf.style.display="none";
            }
        }
        document.onwebkitfullscreenchange = fullscreenChanged;
        document.documentElement.onclick = goFullscreen;
        document.onkeydown = goFullscreen;
    </script>
</head>
<body style="margin:0">
    <H1>Click anywhere or press any key to browse <u>Python documentation</u> in fullscreen.</H1>
    <iframe id="main_frame" src="https://docs.python.org" style="width:100%;height:100%;border:none;display:none"></iframe>
</body>
</html>

Note, however, that websites often disallow embedding, e.g. being displayed inside an iframe. The example initially used W3Schools website instead of Python docs, but they set 'X-Frame-Options' header to 'sameorigin' (disallow cross-site embedding) and it stopped working.


P.S. I like the idea of simulating full-blown OS in browser, and it's even better in fullscreen! :) Change your OS!
Also, I am not a web developer. Just thought this question would be interesting to investigate.