Javascript视频无法在ie11上运行

时间:2017-07-10 13:57:55

标签: javascript internet-explorer iframe

问题: 我的视频没有在ie11上显示,我想让它工作,有人有一个优雅的解决方案吗?

我从Internet Explorer 11(ie11)获得的错误列表是:

https security is compromised by res://ieframe.dll/unknownprotocol.htm 
https security is compromised by res://ieframe.dll/ErrorPageTamplate.css
and so on..

相同的代码适用于firefox,opera,chrome,safari等。

    (function () {
    var iframe = document.createElement("iframe");
    iframe.src = "video.mp4";
    iframe.width = "${width}";
    iframe.height = "${height}";
    iframe.marginHeight = "0";
    iframe.marginWidth = "0";
    iframe.frameBorder = "0";
    iframe.scroling = "no";
    document.getElementById("${someElementId}").appendChild(iframe);
})();

1 个答案:

答案 0 :(得分:0)

我建议您使用http://videojs.com等视频javascript库。该库确保您的代码可以在各种设备上运行,确保即使是像IE6 +这样的旧浏览器也可以运行Flash applet来运行视频。

<html>
<head>
  <link href="http://vjs.zencdn.net/5.8.8/video-js.css" rel="stylesheet">

  <!-- If you'd like to support IE8 -->
  <script src="http://vjs.zencdn.net/ie8/1.1.2/videojs-ie8.min.js"></script>
</head>
<body>
<video class="video-js" data-setup='{}'>
  <source src="video.mp4" type="video/mp4">
</video>
</body>
</html>