本文介绍了无法从iframe切换到全屏模式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个带有按钮的Backbone视图,单击该按钮应可使该视图全屏显示.我正在使用 screenfull.js ,但我看不出与示例和代码有什么不同.但是console.log(screenfull.enabled);始终在clickHandler中返回false.
I have a Backbone view with a button that should make the view goto fullscreen on click. I'm using screenfull.js, and I cant see any different from the examples and my code. But console.log(screenfull.enabled); always return false in the clickHandler.
var FullScreenButton = Backbone.Marionette.ItemView.extend({ tagName: 'button', initialize: function () { this.$el.click(_.bind(this.goFullScreen, this)); }, goFullScreen: function () { console.log(screenfull.enabled); screenfull.request(this.options.container); } });也没有screenfull.js,也不会全屏显示:
also without screenfull.js it dont g oto fullscreen:
goFullScreen: function() { var element = document.documentElement; if (element.requestFullScreen) { element.requestFullScreen(); } else if (element.mozRequestFullScreen) { element.mozRequestFullScreen(); } else if (element.webkitRequestFullScreen) { element.webkitRequestFullScreen(); } }推荐答案
问题是该应用程序在iframe中运行.在iframe中添加allowFullScreen="true"属性可修复该错误.
The problem is that the app runs in an iframe. Adding the allowFullScreen="true" attribute to the iframe fixes the bug.
更多推荐
无法从iframe切换到全屏模式
发布评论