且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

javascript addEventListener onStateChange在IE中不起作用

更新时间:2022-12-18 10:38:10

from testing in IE it looks like the reference you are using

ytswf = document.getElementById('ytplayer1');

在加载实际swf对象之前分配,因此IE认为你指的是一个简单的div元素

is assigned before the actual swf object is loaded, so IE thinks you are referring to a simple div element

你需要运行这段代码

function on***PlayerReady(playerId) {
  ytswf = document.getElementById("ytplayer1");
  ytplayer.addEventListener("onStateChange", "onytplayerStateChange");
}

您致电后

swfobject.embedSWF("http://www.***.com/v/SPWU-EiulRY?
hl=en_US&hd=0&rel=0&fs=1&autoplay=1&enablejsapi=1&playerapiid=ytvideo1",
"popupVideoContainer1", "853", "505", "8", null, null, params, atts);

关闭 $(function()

并在<之后放置 var ytswf;
脚本>

而不是进一步下降

and place var ytswf; right after the <script> instead of further down