使用javascript定位flash对象

时间:2013-07-02 13:07:52

标签: javascript css positioning flash

如果浏览器是互联网eplorer,我想将代码document.getElementById("flashobj").style.left = "260px";右侧列旁边的flash对象移动但是它不起作用。我无法理解这个问题。

Here is a demo. It may help

提前致谢。

<div id="flashobj">You need Flash player 10+ and JavaScript enabled to view this video.</div>

    <div id="banner">
    </div>

     <form id="combination" action="index.php" method="get" name="combination" target="_self">
                    <div class="FixedHeightContainer">
                        <div class="TContent">
                            <input type="hidden" name="view" value="" />
                        </div> 
                    </div>
    </form>


    <script type="text/javascript">
        navigator.sayswho= (function(){
            var N= navigator.appName, ua= navigator.userAgent, tem;
            var M= ua.match(/(opera|chrome|safari|firefox|msie)\/?\s*(\.?\d+(\.\d+)*)/i);
            if(M && (tem= ua.match(/version\/([\.\d]+)/i))!= null) M[2]= tem[1];
            M= M? [M[1], M[2]]: [N, navigator.appVersion,'-?'];
            return M;
        })();

        var browser=navigator.sayswho;
        if(browser[0] == 'MSIE')
        {
            document.getElementById("flashobj").style.left = "260px";
        }




      swfobject.addLoadEvent( ytplayer_render_player );
      function ytplayer_render_player( )
      {
        var so = swfobject.embedSWF
        (
          'http://www.youtube.com/apiplayer?video_id=_vx1OVLX5Rc&enablejsapi=1&autoplay=1&loop=1&version=3&rel=0&fs=1&playerapiid=ytplayer',
          'flashobj',
          600,
          400,
          '10',
          null,
          null,
          {
            allowScriptAccess: 'always',
            allowFullScreen: 'true'
          },
          {
            id: 'flashobj'
          }
        );
      }

1 个答案:

答案 0 :(得分:0)

确保在您尝试定位的元素上设置位置相对(或绝对或固定)。