我有一个带有按钮的主干 View ,单击该按钮应该使 View 转到全屏。我正在使用 screenfull.js ,我看不出示例和我的代码有什么不同。但是 console.log(screenfull.enabled);
总是在 clickHandler 中返回 false
。
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 它不会进入全屏:
goFullScreen: function() {
var element = document.documentElement;
if (element.requestFullScreen) {
element.requestFullScreen();
} else if (element.mozRequestFullScreen) {
element.mozRequestFullScreen();
} else if (element.webkitRequestFullScreen) {
element.webkitRequestFullScreen();
}
}
最佳答案
问题是该应用程序在 iframe 中运行。将 allowFullScreen="true"
属性添加到 iframe 可修复此错误。
关于javascript - 无法从 iframe 切换到全屏模式,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18491330/