Browser security rejecton: Failed to execute 'requestFullscreen' on 'Element': API can only be initiated by a user gesture.
See original GitHub issueHow 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:
- Created 6 years ago
- Comments:5 (3 by maintainers)
Top 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 >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Yes, I will update it later.
@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 thetoggle
method directly from a click callback or the chain of it now.