【问题标题】:youtube js api, internet explorer(8+, inc. 10) "SCRIPT438: Object doesn't support property or method 'playVideo' "youtube js api, internet explorer(8+, inc. 10) “SCRIPT438: 对象不支持属性或方法‘playVideo’”
【发布时间】:2014-06-29 00:37:44
【问题描述】:

视频的 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 之外的所有浏览器,我该怎么办?

【问题讨论】:

    标签: javascript internet-explorer youtube-api youtube-javascript-api


    【解决方案1】:

    原因确实很简单,因为 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;
    }
    

    【讨论】:

      猜你喜欢
      • 2012-08-22
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2023-03-22
      • 1970-01-01
      相关资源
      最近更新 更多