admin管理员组

文章数量:1287720

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

}

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

}
Share Improve this question edited Aug 28, 2013 at 18:15 Andreas Köberle asked Aug 28, 2013 at 14:51 Andreas KöberleAndreas Köberle 111k58 gold badges280 silver badges307 bronze badges
Add a ment  | 

1 Answer 1

Reset to default 12

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

本文标签: javascriptCant switch to fullscreen mode from an iframeStack Overflow