Jake
Jake

Reputation: 185

javascript/jquery : force browser to fullscreen on android

I am writing a web app for a specific android device. This "website" schould be displayed in fullscreen mode.

I found the code above here in stack overflow and it works fine with an click event, although the page should automaticaly open and stay in fullscreen when I am entering the site.

I understand the code, but the load event does not work. Is there any way, javascript, jquery to archieve this goal?

<script>
var el = document.documentElement,
rfs = el.requestFullscreen
      || el.webkitRequestFullScreen
      || el.mozRequestFullScreen
      || el.msRequestFullscreen
      ;
     rfs.call(el);
</script>

Upvotes: 2

Views: 7338

Answers (2)

user2267175
user2267175

Reputation: 593

The javascript fullscreen API can only be invoked by a user interaction, like a mouse/pointer click.

The reason being protecting the end-user from invasive websites. like for example, entering fullscreen or locking the pointer(on a pc) when opening the site.

Upvotes: 1

Jake
Jake

Reputation: 185

Launching a website in fullscreen can be archieved via Google's web app feature and Chrome mobile.

Add this to your :

<link rel="manifest" href="manifest.json">
<meta name="mobile-web-app-capable" content="yes">
<link rel="icon" sizes="192x192" href="ico_lg.png">

And finally the manifest.json explanation by Mozilla https://developer.mozilla.org/en-US/Add-ons/WebExtensions/manifest.json

Here are some other tipps from Google regarding full screen mode: https://developers.google.com/web/fundamentals/native-hardware/fullscreen/

Upvotes: 0

Related Questions