1. <small id='xRB29'></small><noframes id='xRB29'>

  2. <tfoot id='xRB29'></tfoot>

    1. <legend id='xRB29'><style id='xRB29'><dir id='xRB29'><q id='xRB29'></q></dir></style></legend>
    2. <i id='xRB29'><tr id='xRB29'><dt id='xRB29'><q id='xRB29'><span id='xRB29'><b id='xRB29'><form id='xRB29'><ins id='xRB29'></ins><ul id='xRB29'></ul><sub id='xRB29'></sub></form><legend id='xRB29'></legend><bdo id='xRB29'><pre id='xRB29'><center id='xRB29'></center></pre></bdo></b><th id='xRB29'></th></span></q></dt></tr></i><div id='xRB29'><tfoot id='xRB29'></tfoot><dl id='xRB29'><fieldset id='xRB29'></fieldset></dl></div>
      • <bdo id='xRB29'></bdo><ul id='xRB29'></ul>

      Javascript addEventListener onStateChange 在 IE 中不起作用

      时间:2023-09-06
      <i id='9XHvT'><tr id='9XHvT'><dt id='9XHvT'><q id='9XHvT'><span id='9XHvT'><b id='9XHvT'><form id='9XHvT'><ins id='9XHvT'></ins><ul id='9XHvT'></ul><sub id='9XHvT'></sub></form><legend id='9XHvT'></legend><bdo id='9XHvT'><pre id='9XHvT'><center id='9XHvT'></center></pre></bdo></b><th id='9XHvT'></th></span></q></dt></tr></i><div id='9XHvT'><tfoot id='9XHvT'></tfoot><dl id='9XHvT'><fieldset id='9XHvT'></fieldset></dl></div>

            <bdo id='9XHvT'></bdo><ul id='9XHvT'></ul>

              <tfoot id='9XHvT'></tfoot>
                <tbody id='9XHvT'></tbody>
            • <legend id='9XHvT'><style id='9XHvT'><dir id='9XHvT'><q id='9XHvT'></q></dir></style></legend>

                <small id='9XHvT'></small><noframes id='9XHvT'>

                本文介绍了Javascript addEventListener onStateChange 在 IE 中不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                问题描述

                我有两个颜色框弹出框,每个框都显示一个 YouTube 视频.当他们完成播放时,我试图让他们自动关闭彩盒窗口.下面的代码在 Firefox 中完美运行,但在 IE 中我无法让 addEventListener 工作.我试过 attachEvent 没有成功.任何人都可以就如何解决这个问题提供任何建议吗?这看起来很简单,但我已经筋疲力尽地试图找到解决方案.

                I have two colorbox popup boxes which show a YouTube video in each. When they're finished playing, I'm trying to have them automatically close the colorbox window. This code below works perfect in Firefox, but in IE I can't get addEventListener to work. I've tried attachEvent with no success. Can anybody offer any suggestions as to how to solve this? It seems simple but I'm exhausted trying to find a solution.

                更新 1:

                嗯,这是我当前的代码.它在 Firefox 中完美运行,但 IE 仅输出良好.IE8 调试器也不报任何错误...

                Well, this is my current code. It works perfect in Firefox, but IE only outputs good. IE8 debugger doesn't report any errors either...

                function onYouTubePlayerReady(playerId) {
                  if (playerId && playerId != 'undefined') {
                    if(playerId && playerId == 'ytvideo1'){
                      var ytswf = document.getElementById('ytplayer1');
                      alert('good');
                    } else if(playerId && playerId == 'ytvideo2'){
                      var ytswf = document.getElementById('ytplayer2');
                    } else {
                    }
                
                    setInterval('', 1000);
                    ytswf.addEventListener('onStateChange', 'onytplayerStateChange');
                    alert('great');
                  }
                }
                
                
                function onytplayerStateChange(newState) {
                  alert('amazing');
                  if(newState == 0){
                    $.fn.colorbox.close();
                    alert('perfect');
                  }
                }
                

                更新 3:解决方案

                只需将 onComplete 放入我的颜色框中,然后将 swfobject 放入其中即可在 IE 中完美运行.

                Simply put onComplete in my colorbox and put the swfobject in that and it worked perfectly in IE.

                推荐答案

                在 IE 中测试看起来像你正在使用的参考

                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 onYouTubePlayerReady(playerId) {
                  ytswf = document.getElementById("ytplayer1");
                  ytplayer.addEventListener("onStateChange", "onytplayerStateChange");
                }
                

                在你打电话后

                swfobject.embedSWF("http://www.youtube.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;<script> 之后而不是进一步向下

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

                这篇关于Javascript addEventListener onStateChange 在 IE 中不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                上一篇:检查 YouTube 视频是直播还是上传 下一篇:嵌入式 YouTube 视频 showinfo 与谦虚品牌不兼容?

                相关文章

                <legend id='Xi1ME'><style id='Xi1ME'><dir id='Xi1ME'><q id='Xi1ME'></q></dir></style></legend>
                • <bdo id='Xi1ME'></bdo><ul id='Xi1ME'></ul>
                <tfoot id='Xi1ME'></tfoot>
                <i id='Xi1ME'><tr id='Xi1ME'><dt id='Xi1ME'><q id='Xi1ME'><span id='Xi1ME'><b id='Xi1ME'><form id='Xi1ME'><ins id='Xi1ME'></ins><ul id='Xi1ME'></ul><sub id='Xi1ME'></sub></form><legend id='Xi1ME'></legend><bdo id='Xi1ME'><pre id='Xi1ME'><center id='Xi1ME'></center></pre></bdo></b><th id='Xi1ME'></th></span></q></dt></tr></i><div id='Xi1ME'><tfoot id='Xi1ME'></tfoot><dl id='Xi1ME'><fieldset id='Xi1ME'></fieldset></dl></div>

                  1. <small id='Xi1ME'></small><noframes id='Xi1ME'>