2011-11-28 76 views
0

我有一個頁面有3個腳本:idTabs,燈箱(來自Dreamweaver)和手風琴(也來自Dreamweaver)。我做了一些測試:燈箱不適合手風琴。他們中的每一個人都能正常工作,但是手風琴聯合出現故障,不起作用和燈箱工作。 這裏是一些代碼:lightbox手風琴衝突

<link href="style.css" rel="stylesheet" type="text/css" media="screen"> 
<script type="text/javascript" src="jquery.idTabs.min.js"></script> 
<script src="jquery-ui-1.7.2/js/jquery-1.3.2.min.js" type="text/javascript"></script> 
<script src="jquery-ui-1.7.2/js/jquery-ui-1.7.2.min.js" type="text/javascript> 

</script> 
<script src="scripts/jquery.js" type="text/javascript"></script> 
<script src="scripts/lightbox.js" type="text/javascript"></script> 
<link href="jquery-ui-1.7.2/css/base/ui.core.css" rel="stylesheet" type="text/css" /> 
<link href="jquery-ui-1.7.2/css/base/ui.accordion.css" rel="stylesheet" type="text/css" /> 
<link href="jquery-ui-1.7.2/css/base/ui.theme.css" rel="stylesheet" type="text/css" /> 
<link href="jquery-ui-1.7.2/css/base/ui.images.css" rel="stylesheet" type="text/css" /> 

<script type="text/xml"> 
<!-- 
<oa:widgets> 
    <oa:widget wid="2028523" binding="#jQueryUIAccordion" /> 
    <oa:widget wid="2127022" binding="#gallery" /> 
</oa:widgets> 
--> 
</script> 
<link href="css/lightbox.css" rel="stylesheet" type="text/css" /> 
<link href="css/sample_lightbox_layout.css" rel="stylesheet" type="text/css" /> 

這是在<head>

這是收藏

 <script type="text/javascript"> 
// BeginOAWidget_Instance_2127022: #gallery 
    $(function(){ 
     $('#gallery a').lightBox({ 
      imageLoading:   '/images/lightbox/lightbox-ico-loading.gif',  // (string) Path and the name of the loading icon 
      imageBtnPrev:   '/images/lightbox/lightbox-btn-prev.gif',   // (string) Path and the name of the prev button image 
      imageBtnNext:   '/images/lightbox/lightbox-btn-next.gif',   // (string) Path and the name of the next button image 
      imageBtnClose:   '/images/lightbox/lightbox-btn-close.gif',  // (string) Path and the name of the close btn 
      imageBlank:    '/images/lightbox/lightbox-blank.gif',   // (string) Path and the name of a blank image (one pixel) 
      fixedNavigation:  false,  // (boolean) Boolean that informs if the navigation (next and prev button) will be fixed or not in the interface. 
      containerResizeSpeed: 400,    // Specify the resize duration of container image. These number are miliseconds. 400 is default. 
      overlayBgColor:   "#999999",  // (string) Background color to overlay; inform a hexadecimal value like: #RRGGBB. Where RR, GG, and BB are the hexadecimal values for the red, green, and blue values of the color. 
      overlayOpacity:   .6,  // (integer) Opacity value to overlay; inform: 0.X. Where X are number from 0 to 9 
      txtImage:    'Image',    //Default text of image 
      txtOf:     'of' 
     }); 
    }); 

// EndOAWidget_Instance_2127022 
     </script> 

這是手風琴

<script type="text/javascript"> 
    // BeginOAWidget_Instance_2028523: #jQueryUIAccordion 
    $(function(){ 
        // Accordion 
        $("#jQueryUIAccordion").accordion({ header: "h3", 
              >   animated: "slide", 
    event: "click", 
    collapsible : "false" 
    });   
      }); 

    // EndOAWidget_Instance_2028523 
      </script> 
      <!-- Accordion --> 
      <div id="jQueryUIAccordion" class="ui-gray-icons "> 
       <div> 
       <h3><a href="#">First</a></h3> 
       <div> Vivamus rutrum, sapien ac fermentum imperdiet, nisi libero mattis quam, eu mollis sem metus id ligula. </div> 
       </div> 
       <div> 
       <h3><a href="#">Second</a></h3> 
       <div>it, tristique egestas erat interdum id.</div> 
       </div> 
       <div> 
       <h3><a href="#">Third</a></h3> 
       <div>Nam dui erat, auctor a, dignissim quis.</div> 
       </div> 

我希望我沒有失去你。我想強調,我沒有對劇本做任何修改!它們與我從Dreamweaver中添加的相同。謝謝 !

更新:我解決了這個問題。對於有這個問題的其他用戶,只需從lightbox中刪除jquery,手風琴的jquery將照顧燈箱和手風琴!它可以關閉

後更新。我觀察到只有歌劇加載OK手風琴和燈箱。 Firefox並沒有加載手風琴和燈箱。這是控制檯錯誤: [12:56:53.907] $(「#jQueryUIAccordion」)。accordion is not a function @http://localhost/SITE/incercare3.php#:190 [12:56:53.969] $(「#gallery a」)。lightBox is not a功能@http://localhost/SITE/incercare3.php#:275

鉻也犯規加載2個腳本:這是錯誤鉻給我:

未捕獲的類型錯誤:對象[對象的對象]無方法「手風琴」 未捕獲的類型錯誤:對象[對象的對象]沒有方法'lightBox'

意見?

回答

1

第一件事你加載jquery兩次。這會導致衝突。

其次,我只看到了包含在你的頭文件中的lightbox和idTabs腳本,手風琴插件在哪裏?

idTabs是在jquery之前加載的bean,使它在jquery之後加載。

看看您的jQuery版本,您使用的插件需要同時使用jQuery 1.7和1.3,否則會發生衝突。

無論如何,您可以使用jQuery.noConflict()同時使用這兩個版本。

你只是一個提示,以研究JavaScript中的一點:https://developer.mozilla.org/en/JavaScript/Guide

+1

jQuery UI的1.7手風琴! –

+0

好的,但jquery ui使用jQuery 1.3,並且爲你的lightbox裝載一個更新的jquery,它會重載$ global var,並且你將失去手風琴功能。在jquery noConflict文檔中,其他一些文檔也存在相同的問題....嘗試使用noConflict加載第二個javascript實例,並使用像$$這樣的不同變量。然後在新窗口中添加更新的插件。$$引用更新的jQuery –