IE不支持addEventListener方法。试着重新处理。
我正试图在我的网站上运行YT播放器,但IE8和IE9出现问题-播放器没有加载。http://code.google.com/intl/pl/apis/youtube/youtube_player_demo.html
代码:
$(document).ready(function() {
loadPlayer('{$videos[0].videoID}','{$playlist}');
}
function onYouTubePlayerReady(playerId) {
ytplayer = document.getElementById("ytPlayer");
ytplayer.addEventListener("onError", "onPlayerError");
ytplayer.addEventListener("onStateChange", 'onStateChange');
}
function loadPlayer(ytID,ytList) {
var videoID = ytID;
var params = {
allowScriptAccess: "always",
allowFullScreen: true
};
var atts = {
id: "ytPlayer"
};
swfobject.embedSWF("http://www.youtube.com/v/" + videoID +
"?version=3&enablejsapi=1&playerapiid=player1&autohide=1&showinfo=0&autoplay=1&controls=1&loop=1&fs=1&origin=http://www._____.com&playlist="+ytList+'&key='+devKey,
"videoDiv", "620", "350", "9", null, null, params, atts);
}
我不知道这是否会导致问题(在任何环境中都不应该工作),但第3
:行出现语法错误
}
你没有关闭ready()
,应该是:
});