question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

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

See original GitHub issue

How to reproduce:

vue init webpack fullscreen-test
cd fullscreen-test
npm install --save vue-fullscreen
npm run dev

Edit ./src/components/HelloWorld.vue

<template>
  <div class="hello">
    <fullscreen :fullscreen.sync="fullscreen">
      Content
    </fullscreen>
    <button type="button" @click="toggle" >Fullscreen</button>
  </div>
</template>

<script>
import fullscreen from 'vue-fullscreen'
import Vue from 'vue'
Vue.use(fullscreen)

export default {
  name: 'HelloWorld',
  methods: {
    toggle () {
      this.fullscreen = !this.fullscreen
    }
  },
  data () {
    return {
      msg: 'Welcome to Your Vue.js App',
      fullscreen: false
    }
  }
}
</script>

Research:

// Not working through vue-fullscreen recommended method
<button type="button" @click="toggle" >vue-fullscreen</button>

// Works with direct-called plain mozilla fulscreen-request
<button type="button" onclick="body.mozRequestFullScreen()" >onclick fullscreen</button>

// Works with plain mozilla fulscreen-request called from vuejs method
<button type="button" @click="full" >vue-method fullscreen</button>
methods: {
  toggle () {
    this.fullscreen = !this.fullscreen
  },
  full () {
    document.body.mozRequestFullScreen()
  }
}

Tested in Chrome, Fireox

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

2reactions
miraricommented, Feb 14, 2018

Yes, I will update it later.

1reaction
miraricommented, May 25, 2018

@BartlomiejSkwira Since the prop watcher can not be a sync action now, the browser will intercept the subsequent operation of the callback.Change the fullscreen variable or trigger from it will not work. You have to excute the toggle method directly from a click callback or the chain of it now.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Failed to execute 'requestFullScreen' on 'Element': API can ...
I want to make my HTML5 game go native fullscreen on launch. When I do this with a button onclick, it goes fullscreen....
Read more >
User Gesture Restricted Web APIs - JavaScript in Plain English
This error means that the API which you are trying to call cannot just be called in your code, it needs to be...
Read more >
Element.requestFullscreen() - Web APIs | MDN
The Element.requestFullscreen() method issues an asynchronous request to make the element be displayed in fullscreen mode.
Read more >
API can only be initiated by a user gest - YouTube
HTML : Failed to execute ' requestFullScreen ' on ' Element ': API can only be initiated by a user gesture [ Gift...
Read more >
Safari Technology Preview Release Notes - Apple Developer
Fixed highlighting only the initiated resources when a row is hovered ... Added browser.storage.session API for storing data in-memory that is not written ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found