困惑,爲什麼我的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:
- 我正在使用舊的JQuery庫 - 由於傳統等等,客戶端所需要的。我使用1.3.2。
- 我已經添加了一個.gallery_wrap選擇器到JQuery中的ul規則,這樣JQuery就不會在頁面上用母體div來包裝每個列表。
- 由於我知道圖像的大小,我將var theWidth的大小設置爲790px,這固定了一個問題,該圖庫沒有顯示在燈箱內部(沒有靜態寬度,沒有大小計算工作被設置爲顯示的內容:無)。
假設1:由於舊的JQuery版本,Firefox的負邊界行爲沒有被觸發。假設2:添加一個靜態寬度已經與Firefox的負邊距計算相混淆。
任何更好的假設,其他瀏覽器信息它不工作/其他方式失敗,或如何解決它的建議將不勝感激。
檢查控制檯它返回以下錯誤 **的HTML字符編碼文件沒有被宣佈。如果文檔包含US-ASCII範圍之外的字符,則該文檔將在某些瀏覽器配置中呈現亂碼文本。頁面的字符編碼必須在文檔或傳輸協議中聲明** – chhameed 2012-08-02 09:12:56
頭標籤也沒有正確關閉 – chhameed 2012-08-02 09:15:40
謝謝,頭標籤錯誤令人尷尬,但我不認爲這些導致問題。下面修復。 – Ila 2012-08-02 12:16:39