2012-08-02 31 views
0

困惑,爲什麼我的JQuery圖像滑塊不能在Firefox中工作。在Safari瀏覽器&中工作正常,但尚未在IE中進行測試。這是一個基本的點擊一個按鈕,和在下一圖像,幻燈片,跨,看到它在這裏的行動:爲什麼這個jquery內容滑塊可以在Chrome瀏覽器和Safari瀏覽器中使用,但不是Firefox?

http://www.alihaberfield.com/test/carouseltest/carouseltest.html

這裏的JQuery的:

$(window).load(function() { 


var theImage = $('.gallery_wrap ul li img'); 
var theWidth = 790; 
//wrap into mother div 
$('.gallery_wrap ul').wrap('<div id="mother" />');     
//assign height width and overflow hidden to mother 
$('#mother').css({ 
    width: 790, 
    height: 780, 
    position: 'relative', 
    overflow: 'hidden'  
}); 
    //get total of image sizes and set as width for ul 
var totalWidth = theImage.length * theWidth; 
$('.gallery_wrap ul').css({ 
    width: function(){ 
    return totalWidth; 
}    
});  
$(theImage).each(  
    function(intIndex){    
      $(this).nextAll('a') 
      .bind("click", function(){ 
       if($(this).is(".next")) { 

        $(this).parent('li').parent('ul').animate({ 
         "margin-left": (-(intIndex + 1) * theWidth)    
        }, 1000)      

       } else if($(this).is(".previous")){ 

        $(this).parent('li').parent('ul').animate({ 
         "margin-left": (-(intIndex - 1) * theWidth)    
        }, 1000)  


       } else if($(this).is(".startover")){ 

        $(this).parent('li').parent('ul').animate({ 
         "margin-left": (0)    
        }, 1000) 

       } 
      });//close .bind()         
});//close .each()      
});//doc ready 

它是基於這個簡單的jQuery滑塊,我將不會注意工作在Firefox:

http://brenelz.com/blog/build-a-content-slider-with-jquery/

該滑塊之間的主要區別和我的塔t:

  1. 我正在使用舊的JQuery庫 - 由於傳統等等,客戶端所需要的。我使用1.3.2。
  2. 我已經添加了一個.gallery_wrap選擇器到JQuery中的ul規則,這樣JQuery就不會在頁面上用母體div來包裝每個列表。
  3. 由於我知道圖像的大小,我將var theWidth的大小設置爲790px,這固定了一個問題,該圖庫沒有顯示在燈箱內部(沒有靜態寬度,沒有大小計算工作被設置爲顯示的內容:無)。

假設1:由於舊的JQuery版本,Firefox的負邊界行爲沒有被觸發。假設2:添加一個靜態寬度已經與Firefox的負邊距計算相混淆。

任何更好的假設,其他瀏覽器信息它不工作/其他方式失敗,或如何解決它的建議將不勝感激。

+0

檢查控制檯它返回以下錯誤 **的HTML字符編碼文件沒有被宣佈。如果文檔包含US-ASCII範圍之外的字符,則該文檔將在某些瀏覽器配置中呈現亂碼文本。頁面的字符編碼必須在文檔或傳輸協議中聲明** – chhameed 2012-08-02 09:12:56

+0

頭標籤也沒有正確關閉 – chhameed 2012-08-02 09:15:40

+0

謝謝,頭標籤錯誤令人尷尬,但我不認爲這些導致問題。下面修復。 – Ila 2012-08-02 12:16:39

回答

0

正確答案:腳本與舊版本的JQuery無法正常工作。

使用Jquery 1.3將無法在Firefox(或IE,因爲它發生)中工作。使用JQuery 1.4及更高版本在所有瀏覽器中完美工作。

問題通過加載兩個庫和使用中的出色答案本頁提供了jQuery noconflict結構解決:

jQuery No Conflict Still Conflicts with Other Version of jQuery

相關問題