- Ϊʲô»áÓÐreadyº¯Êý
- ͨ³£ÈçºÎÅжÏ
- jQueryÖÐÈçºÎʵÏÖ
Ô´Âëչʾ:
ready: function( fn ) {
jQuery.bindReady(); //Ìí¼Ó¼àÌýº¯Êý
if ( jQuery.isReady ) { //Èç¹ûdom¼ÓÔØÍê³ÉÁË
fn.call( document, jQuery ); //Á¢¿ÌÖ´Ðк¯Êý
} else if ( readyList ) {
readyList.push( fn ); //·ñÔò°Ñº¯ÊýÌí¼Ó½øreadyList
}
return this;
},
2. jQuery.ready() Ö´Ðа󶨵ĺ¯Êý¶ÓÁÐ
ready: function() { if ( !jQuery.isReady ) { ¡¡¡¡ if ( !document.body ) { return setTimeout( jQuery.ready, 13 ); } jQuery.isReady = true; //ÉèÖÃisReady if ( readyList ) { var fn, i = 0; while ( (fn = readyList[ i++ ]) ) { fn.call( document, jQuery ); } readyList = null; } if ( jQuery.fn.triggerHandler ) { jQuery( document ).triggerHandler( "ready" ); } } }3. bindReady() °ó¶¨Ê¼þ¼àÌýÆ÷µÄ·½·¨ ÆÁ±ÎÁËä¯ÀÀÆ÷µÄ²îÒì
¿´¿´bindReadyµÄʵÏÖ
bindReady: function() {
if ( readyBound ) { //ĬÈÏΪfalse
return;
}
¡¡¡¡readyBound = true;
if ( document.readyState === "complete" ) {
return jQuery.ready();
}
if ( document.addEventListener ) { document.addEventListener("DOMContentLoaded",DOMContentLoaded, false );
window.addEventListener( "load", jQuery.ready, false );
} else if ( document.attachEvent ) {
document.attachEvent("onreadystatechange", DOMContentLoaded);
window.attachEvent( "onload", jQuery.ready );
var toplevel = false;
¡¡¡¡ try {
toplevel = window.frameElement == null;
} catch(e) {}
if ( document.documentElement.doScroll && toplevel ) {
doScrollCheck();
}
}
}
4. doScrollCheck() ΪIEä¯ÀÀÆ÷²âÊԵķ½·¨
function doScrollCheck() { if ( jQuery.isReady ) { return; } try { document.documentElement.doScroll("left"); } catch( error ) { setTimeout( doScrollCheck, 1 ); return; } //²»Í£µÄÖ´ÐÐdocument.documentElement.doScroll("left") jQuery.ready(); }4. DOMContentLoaded() ÒƳýÁ˰󶨵ÄDOMContentLoaded¼àÌýÆ÷£¬²¢ÇÒµ÷ÓÃjQuery.ready()·½·¨
DOMContentLoaded = function() { document.removeEventListener( "DOMContentLoaded", DOMContentLoaded, false ); jQuery.ready(); };
²Î¿¼ÏÂÃæÎÄÕÂ:http://www.javaeye.com/topic/818329#1767310
ÍƼöÐÅÏ¢
- jqueryʵÏÖÍøվͼƬÀÁ¼ÓÔØ´úÂë
- jQuery Tooltips²å¼þ
- jQueryµÄ.bind()¡¢.live()ºÍ.delegate(....
- [Ô´´]·ÂGoogle Reader¡¢ÐÂÀË΢²©¡¢ÌÚѶ΢²©µ....
- Ä㲻ϲ»¶»ðºü£¬µ«ÓÖϲ»¶firebug£¬ÄǾ͸úÎÒÒ»ÆðÀ´ÔÚIEÉÏ....
- ¸ù¾ÝÏÔʾÆ÷·Ö±æÂʵ÷ÕûÒ³ÃæÏÔʾµÄJavascript½Å±¾
- jQuery дµÄ·ÂÐÂÀË΢²© ÏòϹö¶¯Ð§¹û¡¾×ªÔØ¡¿
- ͨÓõÄJqueryÑ¡ÔñÆ÷
- jQuery ½áºÏ Json Ìá½»Êý¾Ýµ½Webservice£¬....
- ×ÔÖÆjQueryÖÇÄÜÌáʾ²å¼þһö
ÈÈÃÅÐÅÏ¢
- nohup: redirecting stderr to stdou....
- ʹÓÃlog_formatΪNginx·þÎñÆ÷ÉèÖøüÏêϸµÄÈÕÖ¾¸ñʽ
- jquery easyUI--dataGrid-Json
- [Ô´´]·ÂGoogle Reader¡¢ÐÂÀË΢²©¡¢ÌÚѶ΢²©µ....
- ÀûÓÃKeepalived+mysql¹¹½¨¸ß¿ÉÓÃMySQLË«Ö÷×Ô¶....
- Nginx+keepalivedʵÏÖ¸ºÔؾùºâºÍË«»úÈȱ¸¸ß¿ÉÓÃ
- jqueryʵÏÖÒ³Ãæ¼ÓÔؽø¶ÈÌõ
- Rolling cURL: PHP²¢·¢×î¼Ñʵ¼ù
- codeigniter ·ÓÉÖÕ¼«ÓÅ»¯(url rewrite)
- linuxÏÂÉèÖÃsshÎÞÃÜÂëµÇ¼
×î½ü¸üÐÂ
- js»ñÈ¡srcÖд«µÝµÄ²ÎÊý
- jqueryʵÏÖÍøվͼƬÀÁ¼ÓÔØ´úÂë
- ÈÃä¯ÀÀÆ÷ÆÁ±ÎµôJavaScriptµÄ³ö´íÌáʾ
- github²»ÄܼÓÔØcss¡¢js½â¾ö°ì·¨
- ÎÒÖªµÀµÄJavaScript -- Éè¼Æģʽ(ÇŽÓ)Ó¦ÓÃÖ® ¨C ....
- 15¸öÖµµÃ¿ª·¢ÈËÔ±¹Ø×¢µÄjQuery¿ª·¢¼¼ÇɺÍÐĵÃ
- dz̸JavascriptÃæÏò¶ÔÏó±à³Ì
- JS¼òµ¥¶¯»·â×°
- JavaScript³õѧÕßӦעÒâµÄÆ߸öϸ½Ú
- jQuery Tooltips²å¼þ
ÆÀÂÛ