我在Firefox上打开这个文件它运行正常,但在IE11和IE8上它并没有触发event: onReady
它在网络服务器上运行正常,对于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>
有没有解决这个问题?