Cant switch to fullscreen mode from an iframe

可紊 提交于 2019-12-11 01:09:57

问题


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);
  }
});

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();
  }

}

回答1:


The problem is that the app runs in an iframe. Adding the allowFullScreen="true" attribute to the iframe fixes the bug.



来源:https://stackoverflow.com/questions/18491330/cant-switch-to-fullscreen-mode-from-an-iframe

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!