0
http://www.phpied.com/when-is-a-stylesheet-really-loaded/動態加載的樣式表與回調
使用該解決方案除了在Chrome加載樣式表有回調偉大的工作。
在Chrome(v18)中,我仍然可以看到正在應用的CSS,這會根據動態加載的CSS中的高度和寬度設置鎖定一些其他函數。
任何想法???
謝謝!
http://www.phpied.com/when-is-a-stylesheet-really-loaded/動態加載的樣式表與回調
使用該解決方案除了在Chrome加載樣式表有回調偉大的工作。
在Chrome(v18)中,我仍然可以看到正在應用的CSS,這會根據動態加載的CSS中的高度和寬度設置鎖定一些其他函數。
任何想法???
謝謝!
WebKit中,您可以通過查詢修改document.styleSheets,這裏要說的是做,在lazyload(從https://github.com/rgrove/lazyload/blob/master/lazyload.js拍攝)功能
或者只是使用該插件它的js太:)
function pollWebKit() {
var css = pending.css, i;
if (css) {
i = styleSheets.length;
// Look for a stylesheet matching the pending URL.
while (--i >= 0) {
if (styleSheets[i].href === css.urls[0]) {
finish('css');
break;
}
}
pollCount += 1;
if (css) {
if (pollCount < 200) {
setTimeout(pollWebKit, 50);
} else {
// We've been polling for 10 seconds and nothing's happened, which may
// indicate that the stylesheet has been removed from the document
// before it had a chance to load. Stop polling and finish the pending
// request to prevent blocking further requests.
finish('css');
}
}
}
}
在我自己的代碼中仍然有一些小問題需要解決,但它肯定會使用正確的定時回調加載樣式表。謝謝! – tau 2012-04-13 22:04:17