2011-01-22 74 views
0

我使用jQuery Masonry進行WordPress安裝,並且在除Safari(Win和OSX)之外的每個瀏覽器中都可以正常工作。這可能與一些jQuery/WebKit問題有關嗎?​​發射得太早?我很新的jQuery/JavaScript,所以任何幫助,不勝感激。jQuery砌體不適用於Safari

本頁面在Safari瀏覽器不工作:http://tangomitstil.de/news/

雖然這個頁面(出於某種原因)的作用:http://tangomitstil.de/info/unterricht/

的問題是不相關的(項目數,我遇到了同樣的問題與我的dev版本與一個相當大的測試帖子集),@ font-face嵌入,使用圖像,或Infinite Scroll plugin

這裏是稱爲在報頭部分中的代碼:

jQuery(window).load(function($) { 
    // We can only load masonry on window.load because of embedded swfobjects 
    jQuery('.content').masonry({ 
     singleMode: true, 
     resizable: true, 
     animate: false 
    }); // initiate masonry 
    jQuery('.content').infinitescroll({ 
     navSelector: "div.navigation", 
     // selector for the paged navigation (it will be hidden) 
     nextSelector: "div.navigation div.nav-previous a", 
     // selector for the NEXT link (to page 2) 
     itemSelector: ".content div.post", 
     // selector for all items you'll retrieve 
     loadingText: "Lädt weitere Beiträge..." 
    }, function(newElements) { 
     jQuery(this).masonry({ 
      appendedContent: jQuery(newElements) 
     }); 
    }) 
}); 

回答

2

嘗試使用「DOM就緒」事件,該事件的「負載」事件(當圖像已完成加載等)之後觸發。

jQuery有一個很好的捷徑。取而代之的

jQuery(window).load(function() { 
    // ... 
}); 

jQuery(function() { 
    // ... 
}); 

或者,乾脆:

$(function() { 
    // ... 
}); 

當你不併行使用任何其它JS框架,它是安全和方便的地方使用$jQuery

+0

Thx爲快速回復,但也不起作用。我的內容通過(window).load獲得「masonified」。但是,safari中的「left」屬性始終設置爲0,因此不會呈現第二列。 – 2011-01-23 14:39:47