Youtube api Youtube iframe api:';onReady'';onStateChange';在IE 8中不开火

Youtube api Youtube iframe api:';onReady'';onStateChange';在IE 8中不开火,youtube-api,Youtube Api,我刚刚在IE 8中查看我的youtube播放器,注意到“onReady”、“onStateChange”事件没有触发。正在调用initPlayer方法并播放视频,但事件未触发 在Safari、Firefox Mac和Firefox Win上都能正常工作 我是不是遗漏了什么 以下是相关代码: MyPlayer.prototype = { /* [...] */ initPlayer: function () { var that = this; alert("init

我刚刚在IE 8中查看我的youtube播放器,注意到“onReady”、“onStateChange”事件没有触发。正在调用initPlayer方法并播放视频,但事件未触发

在Safari、Firefox Mac和Firefox Win上都能正常工作

我是不是遗漏了什么

以下是相关代码:

MyPlayer.prototype = {

/*   [...]  */


initPlayer: function () {

    var that = this;
    alert("initPlayer: (IE 8 gets this far)");

    this.player = new YT.Player(this.cfg.divTagId, {
        height:  this.cfg.height,
        width:   this.cfg.width,
        videoId: this.cfg.videoId,
        origin:  location.host,
        playerVars: {
           controls: this.cfg.controls, 
           wmode: 'opaque',
          fs: 0
       },
       events: {
         'onReady': function (event) {alert("onReady")},
         'onStateChange': function (event) {alert("onChange")}
      }
   });
},

/*[……]*/


}这是YouTube api代码中的一个老错误。这一点应该都能正常工作。

一个可能的因素是:如果您在本地运行API,它将无法在IE中正常工作-请尝试从http:path运行代码

资料来源: