Search code examples
javascriptgoogle-chromefullscreen

How to force my Chrome browser to accept .requestFullscreen()?


I am writing an application for myself in which I need to go fullscreen automatically via JavaScript (today I simulate the press of F11, which usually works, but not always).

I would like to use .requestFullscreen() (via screenfull.js) but I get

Failed to execute 'requestFullscreen' on 'Element': API can only be initiated by a user gesture.

This is understandable (for security / spam / usability reasons) and mentioned on numerous pages.

Now, since this is my application running on my Chrome browser, I would like to have the ability to allow this request in my browser. Is this a possible setting for Chrome?


Solution

  • You can use kiosk mode:

    On Windows:

    "C:\Program Files (x86)\Google\Chrome\Application\chrome.exe" --chrome --fullscreen --kiosk http://10.20.30.40/page/
    

    On Linux

    chrome  --chrome --fullscreen --kiosk http://10.20.30.40/page/