YouTube JS API, Internet Explorer(8+, Inc. 10) "SCRIPT438: Object doesn't support property or metho



div与视频最初是隐藏的(与display: none;),但iframe似乎加载得很好,按下一个按钮,我首先将display: none;更改为display: block;,然后做播放器(这是yt播放器的实例)player.playVideo(),没有什么不寻常的,真的。但是它会抛出这个错误。

注销player.playVideo确实返回undefined

记录player,返回这个

{
   "b":{
      "b":{
         "width":1259,
         "height":709,
         "videoId":"videaidhere",
         "playerVars":{
            "autoplay":0,
            "controls":0,
            "showinfo":0,
            "rel":0,
            "modestbranding":1,
            "html5":0,
            "wmode":"transparent"
         }
      },
      "defaults":{
         "host":"http://www.youtube.com",
         "title":"video player",
         "videoId":"",
         "width":640,
         "height":360
      },
      "a":false
   },
   "a":{
      "closure_uid_78774223":2
   },
   "o":{
   },
   "closure_uid_78774223":1,
   "s":1,
   "d":130,
   "u":false,
   "t":[
      {
         "event":"command",
         "func":"addEventListener",
         "args":[
            "onReady"
         ]
      },
      {
         "event":"command",
         "func":"addEventListener",
         "args":[
            "onStateChange"
         ]
      }
   ],
   "g":{
      "a":[
         null,
         "onReady",
         null,
         null,
         "onStateChange",
         null,
         null
      ],
      "b":{
         "onReady":[
            1
         ],
         "onStateChange":[
            4
         ]
      },
      "G":7
   },
   "h":"player",
   "D":{
      "onReady":true,
      "onStateChange":true
   },
   "k":{
   },
   "i":{
   }
}

它适用于所有浏览器,但ie,我该怎么办?

原因确实很简单,因为div最初是隐藏的,您所需要做的就是以其他方式隐藏它,我在visibility: hidden;opacity: 0;上没有真正取得多大成功,top: -alot;以及父overflow: hidden;完成了这项工作。

这段来自Harry Roberts的代码可能也可以完成这项工作。

/**
 * Hide content off-screen without resorting to `display:none;`, also provide
 * breakpoint specific hidden elements.
 */
@mixin accessibility{
    border:0!important;
    clip:rect(0 0 0 0)!important;
    height:1px!important;
    margin:-1px!important;
    overflow:hidden!important;
    padding:0!important;
    position: absolute!important;
    width:1px!important;
}

相关内容

  • 没有找到相关文章

最新更新