2013-07-02 86 views
0

如果瀏覽器是Internet eplorer我想將代碼document.getElementById("flashobj").style.left = "260px";旁邊的閃存對象移動到右邊列但它不起作用。我無法理解這個問題。使用javascript定位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' 
      } 
     ); 
     } 
+0

#flashobj { left:260px; 位置:相對; z-index:1; } – falguni

+0

@falguni如何檢測瀏覽器類型,並設置如果條件與CSS? – Tahtakafa

回答

0

確保位置相對(或絕對或固定)設置在您要設置的元素上。

+0

它已經相對。 – Tahtakafa