2014-04-08 79 views
0

當我使用jquery-1.11.0.min.js時,colorbox不能正確加載視頻。 colorbox div顯示,但沒有加載YouTube視頻。見OADG Dutt Roth video。當我使用jquery-1.7.1時,視頻加載正確。見OADG Horse video。有人可以確定一個能與1.11.0協同工作的解決方案嗎?colorbox iframe不能與jquery工作1.11

<script type="text/javascript" src="../script/jquery-1.11.0.min.js"></script> 
<script type="text/javascript" src="http://code.jquery.com/jquery-1.9.0.js"></script> 
<script type="text/javascript" src="http://code.jquery.com/jquery-migrate-1.2.1.js"></script> 
<script type="text/javascript" src="../script/jquery.colorbox-min.js" charset="utf-8"></script> 
<script type="text/javascript">   
    /*<![CDATA[*/    
    jQuery(document).ready(function(){ 
    jQuery('.youtube').colorbox({iframe: true, width: 853, height: 480, href:function(){ 
    var videoId = new RegExp('[\\?&]v=([^&#]*)').exec(this.href); 
    if (videoId && videoId[1]) { 
     return 'http://youtube.com/embed/'+videoId[1]+'?rel=0&wmode=transparent'; 
    } 
}});   
}); 
/*]]>*/ 
</script> 
<div> 
    <p><a class='youtube' href="http://www.youtube.com/embed/Z_nAZI5dfx0?rel=0" title="Susanne Dutt-Roth Riding D2 March, 2012"><img src="S_DuttRothFeb2012.jpg" title="Susanne Dutt-Roth Riding D2 March, 2012" alt="Susanne Dutt-Roth Riding D2 March, 2012"/></a></p> 
</div> 
+0

我想我找到了問題。請看我的答案。 –

回答

1

jQuery colorbox只與jquery 1.3+兼容。你必須在代碼中引用jquery的更新版本。

「兼容:jQuery的1.3.2+」 http://www.jacklmoore.com/colorbox/

包括你的這個鏈接(http://www.ottawadressage.ca/duttroth/)有一個以上的jQuery文件。請刪除<head>部分中提到的舊版本。

+0

我正在使用jquery 1.11.0,1.7-1被註釋掉了。如果我單獨使用1.11.0或1.9.0,則YouTube視頻會在網頁頂部打開,因爲colorbox.js指向不推薦使用的$ .browser。如果我將1.11.0用於migrate-1.2.1,則會打開colorbox,但不會將視頻下載到該框中。沒有證據表明通過鏈接獲取YouTube視頻。它看起來像1.7.1之後發生了變化,其中帶有視頻的colorbox不起作用。只要圖像被colorbox引用,它就可以在1.11.0中工作。 – user1897732