Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/assembly/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 未在IE localfile上触发onYouTubeIframeAPIReady事件_Javascript_Youtube_Youtube Api_Youtube Javascript Api - Fatal编程技术网

Javascript 未在IE localfile上触发onYouTubeIframeAPIReady事件

Javascript 未在IE localfile上触发onYouTubeIframeAPIReady事件,javascript,youtube,youtube-api,youtube-javascript-api,Javascript,Youtube,Youtube Api,Youtube Javascript Api,我在Firefox上打开了这个文件,它可以正常工作,但在IE11和IE8上,它没有启动事件:onReady它在Web服务器上正常工作,无论是Firefox还是IE <!DOCTYPE html> <html> <head> <!-- // this is needed to force our embedded browser to run in EDGE mode --> <meta http-equiv="X-UA-Compatible"

我在Firefox上打开了这个文件,它可以正常工作,但在IE11和IE8上,它没有启动
事件:onReady
它在Web服务器上正常工作,无论是Firefox还是IE

<!DOCTYPE html>
<html>
<head>
<!-- // this is needed to force our embedded browser to run in EDGE mode -->
<meta http-equiv="X-UA-Compatible" content="IE=edge">
</head>
  <body>
    <!-- 1. The <iframe> (and video player) will replace this <div> tag. -->
    <div id="player"></div>

    <script>

      var tag = document.createElement('script');

      tag.src = "https://www.youtube.com/iframe_api"; //
      var firstScriptTag = document.getElementsByTagName('script')[0];
      firstScriptTag.parentNode.insertBefore(tag, firstScriptTag);

      var player;
      function onYouTubeIframeAPIReady() {
        player = new YT.Player('player', {
          height: '390',
          width: '640',
          videoId: '0Bmhjf0rKe8',
          events: {
            'onReady': onPlayerReady
          }
        });

        }

      function onPlayerReady(event) {
        alert("onReady!");//didn't work on IE localfile
        event.target.playVideo();
      }
    </script>
  </body>
</html>

var tag=document.createElement('script');
tag.src=”https://www.youtube.com/iframe_api"; //
var firstScriptTag=document.getElementsByTagName('script')[0];
firstScriptTag.parentNode.insertBefore(标记,firstScriptTag);
var播放器;
函数onyoutubeiframeapiredy(){
player=新的YT.player('player'{
高度:“390”,
宽度:“640”,
videoId:'0Bmhjf0rKe8',
活动:{
“onReady”:onPlayerReady
}
});
}
函数onPlayerReady(事件){
警报(“onReady!”;//在IE localfile上不起作用
event.target.playVideo();
}

是否有解决方法?

请参见其他问题中的答案: