Re: ÌÖÂÛÒ»ÏÂÌÖÑáµÄscript±êÇ©

¶Ô ÊÇÕâÒâ˼
ʵ¼ÊÉÏ´úÂë¿ÉÄÜÏñÏÂÃ棺

<body>
<div id="content">
</div>
<script type="text/javascript">
 //do something
</script>
<div id="footer">......</div>
</body>
Èç¹ûÎÒÔÚwindow.onload»òÕßdom readyÖ®ºóÔÙÈ¥Ö´ÐкìÉ«µÄ²¿·Ö£¬¿ÉÄÜ»á´ó´óÑÓ³¤Óû§µÚÒ»ÑÛ¿´µ½ÍêÕûÍøÒ³µÄʱ¼ä

µ«ÊÇÏÖÔÚ£¬ÎÒÃÇÖ»ÄÜÔÚ´úÂëÖвåÈëscript±êÇ©À´×öÕâ¼þÊÂ

ÔÚ 2010Äê10ÔÂ22ÈÕ ÏÂÎç7:35£¬John Hax <johnhax@gmail.com>дµÀ£º

> Û¿·ÇµÄÒâ˼²¢²»ÊÇÕû¸ödom ready£¬¶øÊǵ¥¸öÔªËØ¿ÉÓõÄʼþ¡£
>
>
> ÕâÖÖÐèÇóÊÇ´æÔڵġ£ÒòΪҪ¶ÔÓÐЩԪËØ×öÌØÊâ½Å±¾²Ù×÷£¬Ô½ÔçÔ½ºÃ¡£
>
>
> ±ÈÈç autofocus
>
>
> ĿǰΪÁ˾¡Ôçfocus£¬ÎÒÃDZØÐ룺
> <input id="search" ...>
> <script>$('#search').focus()</script>
>
> ʵ¼ÊÉÏ×îºÃÄÜÕâÑù£º
> <head>
> <script>
> document.addEventListener('elementstart', function (event) {
>   var e = event.target
>   if (e.tagName.toLowerCase() == 'input' && e.id="search") e.focus()
> }, false)
> </script>
> </head>
>
> Õâ¸öÊÇelementstart£¬¼´µ±Ê±elementµÄ×ÓÔªËØ»¹Ã»ÓÐready£¬Ö»ÄÜ»ñµÃ¸ÃelementµÄÊôÐÔ¡£
>
> ÁíÒ»ÖÖÊÇelementend£¬¼´µ±Ê±elementÒѾ­ÍêÈ«ready¡£
>
> ¾Ù¸öÐèÇóµÄÀý×Ó£¬¸ù¾ÝÔ¤ÏÈÖ¸¶¨µÄ·½Ê½¶ÔtableÖеÄÏîÄ¿½øÐÐÅÅÐò£º
>
> var sortTableBy = location.hash
>
> document.addEventListener('elementend', function (event) {
>    var e = event.target
>   if (e.tagName.toLowerCase() == 'table') {
>      sortTableByCol(e, sortTableBy)
>   }
> }, false)
>
>
>
>
> Ä¿Ç°±ê×¼ÊÇûÓÐelementstart/endÕâÖÖʼþµÄ¡£Ö»ÓÐhtc£¨IE6,IE7£©ºÍxbl£¨FF£©²ÅÄܸÉelementendÕâÖÖÊÂÇé¡£
>
> 2010/10/22 OOO <othree@gmail.com>
>
> ¬FÔÚÓÐ DOMContentLoaded ʼþ
>> Ó|°l•régÊÇÔÚ Îļþ˜ä½¨ºÃ £¬é_ʼ render Ç°
>>
>> jQuery µÄ Ready ¾ÍÊÇ•þÏÈ¿´žgÓ[Æ÷Ö®²»Ö§Ô®ß@‚€Ê¼þ
>> ²»Ö§Ô®µÄÔ’(IE)•þ¸ÄÓà IE hack
>> Ò»Ö±Ô‡Öø scroll
>> ›]×xÍêµÄÔ’ scroll ¶¼•þʧ”¡
>>
>> ß@²¿·ÝµÄ×hî}‘ªÔ“ÊÇ DOM µÄ²¿·Ý
>> ºÍ script ˜Ë»`›]êP‚S²ÅÊÇ
>>
>> script ˜Ë»`¬FÔÚÓбÈÝ^²»Í¬µÄÊÇ async ºÍ defer ƒÉ‚€ŒÙÐÔ
>>
>> ÔÚ 2010Äê10ÔÂ22ÈÕÏÂÎç6:59£¬ÖÜÔ£²¨ <itchina110@gmail.com> Œ‘µÀ£º
>>  > ÎҼDz»Ì«Çå³þÁË£¬ºÃÏñÏÖÔÚÊÇÒýÈëÁËÕâÑùÒ»¸öʼþ£¬ÓеãÀàËÆjqueryµÄready·½Ê½
>> > ÔÚ 2010Äê10ÔÂ22ÈÕ ÏÂÎç6:55£¬Û¿·Ç³Ì <csf178@gmail.com>дµÀ£º
>> >>
>> >> ´ó¼ÒÓ¦¸Ã¶¼Óöµ½¹ýÒ»ÖÖ³¡¾°£¬Ò»¶Î½Å±¾ÒªÔÚijһԪËØ´´½¨ÒÔºóÁ¢¼´Ö´ÐУº
>> >>
>> >> <div id="content">
>> >> </div>
>> >> <script type="text/javascript">
>> >>  //do something
>> >> </script>
>> >>
>> >> ÕâÊÇÒ»ÖÖºÜÔã¸âµÄ×ö·¨£¬ÖÁÉÙÓÐ2¸öÑÏÖØÎÊÌ⣺
>> >>
>> >>
>> 1.script±êÇ©½«×èÈûäÖȾỊ̈߳¬ÒòΪҪÕչ˵½document.writeÕâÖÖа¶ñµÄд·¨£¬ºóÃæµÄäÖȾ±ØÐëµÈ´ý½Å±¾Ö´ÐÐÍê±Ï£¬Õâ¶ÔÓÚÒýÓõ¥¶ÀJSÎļþµÄscript±êÇ©¸ü¼ÓÖÂÃü£¬äÖȾ±ØÐëµÈ´ýJSÎļþÏÂÔØ¡£
>> >>
>> >> 2.ÐÐΪºÍ±íÏÖÎÞ·¨³¹µ×·ÖÀ룬JS´úÂëÒ²ÎÞ·¨ºÍHTML´úÂë·ÖÀë
>> >>
>> >> ËùÒÔÎÒÔÚÏëÊÇ·ñ¿ÉÒÔÒýÈëһʼþ
>> >>
>> >> body.onElementLoad=function(element) {
>> >>     if(element.id=="content"){
>> >>         //do something
>> >>     }
>> >> }
>> >>
>> >> ´ó¼Ò˵˵×Ô¼ºµÄÏë·¨
>> >
>> >
>> > --
>> > ´ËÖÂ
>> >
>> > Mr. Zhou YuBo - ÖÜÔ£²¨
>> >
>> >  Óʼþ£ºitchina110@gmail.com
>> >  µç»°£º13717517540
>> >
>>
>>
>>
>> --
>> OOO
>>
>
>

Received on Friday, 22 October 2010 13:11:41 UTC