2011-10-12 52 views

回答

19

看起來您需要將?wmode=transparent添加到YouTube嵌入iframe src的網址。像這樣:

<iframe width="632" height="390" src="http://www.youtube.com/embed/_K-YwgCyg70?wmode=transparent" frameborder="0" allowfullscreen></iframe> 
+0

這不起作用。我收到「發生錯誤,請稍後再試。」消息 – sdleihssirhc

+0

URL需要爲'http://www.youtube.com/embed/_K-YwgCyg70?wmode = transparent'。 @sdleihssirhc:將來的信息。 – thirtydot

+0

是的,對不起。 – Brent

3

可以自動SRC添加參數,所有的I幀像這樣:如果你正在使用嵌入

$(document).ready(function() 
    { 
     $('iframe').each(function() 
     { 
       var url = $(this).attr("src"); 
       var char = "?"; 
       if(url.indexOf("?") != -1) 
         var char = "&"; 

       $(this).attr("src",url+char+"wmode=transparent"); 
     }); 
    }); 
+0

謝謝!這解決了我的問題。 – gonzo

+1

小心 - 當您只需定位YouTube iframe時,這將修改您網頁上的所有iframe。你應該定位那裏的src url包含youtube域名。 –

0

,WMODE需要有一個屬性,而不是URL的一部分wmode="transparent"

0

如果您使用的iframe API,你可以這樣添加它(請注意在playerVars最後的參數對象):

player = new YT.Player(playerID, 
     { 
      width: '100%', 
      height: '100%', 
      videoId: vidID, 
      playerVars: { 
       controls: 2, 
       autohide: 1, 
       showinfo: 0, 
       modestbranding: 1, 
       wmode: 'transparent' 
      } 
     });