无法从iframe切换到全屏模式

编程入门 行业动态 更新时间:2024-10-24 20:23:42
本文介绍了无法从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切换到全屏模式

本文发布于:2023-11-11 23:41:26,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1579868.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:全屏   切换到   模式   iframe

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!