Ò׽ؽØͼÈí¼þ¡¢µ¥Îļþ¡¢Ãâ°²×°¡¢´¿ÂÌÉ«¡¢½ö160KB

Javascript ±Õ°ü


·­Ò룺Ϊ֮Âþ±Ê
Á´½Ó£ºhttp://www.cn-cuckoo.com/2007/08/01/understand-javascript-closures-72.html
¼ò½é
»ùÓÚ¶ÔÏóµÄÊôÐÔÃû½âÎö
ÖµµÄÖ¸¶¨
ÖµµÄ¶ÁÈ¡
±êʶ·û½âÎö¡¢Ö´Ðл·¾³ºÍ×÷ÓÃÓòÁ´
Ö´Ðл·¾³
×÷ÓÃÓòÁ´Óë [[scope]]
±êʶ·û½âÎö
±Õ°ü
×Ô¶¯À¬»øÊÕ¼¯
¹¹³É±Õ°ü
ͨ¹ý±Õ°ü¿ÉÒÔ×öʲô£¿
Àý 1£ºÎªº¯ÊýÒýÓÃÉèÖÃÑÓʱ
Àý 2£ºÍ¨¹ý¶ÔÏóʵÀý·½·¨¹ØÁªº¯Êý
Àý 3£º°ü×°Ïà¹ØµÄ¹¦ÄÜ
ÆäËûÀý×Ó
ÒâÍâµÄ±Õ°ü
Internet Explorer µÄÄÚÔÚй©ÎÊÌâ
¼ò½é
Closure Ëùν“±Õ°ü”£¬Ö¸µÄÊÇÒ»¸öÓµÓÐÐí¶à±äÁ¿ºÍ°ó¶¨ÁËÕâЩ±äÁ¿µÄ»·¾³µÄ±í´ïʽ£¨Í¨³£ÊÇÒ»¸öº¯Êý£©£¬Òò¶øÕâЩ±äÁ¿Ò²ÊǸñí´ïʽµÄÒ»²¿·Ö¡£
±Õ°üÊÇ ECMAScript £¨JavaScript£©×îÇ¿´óµÄÌØÐÔÖ®Ò»£¬µ«ÓúñհüµÄÇ°ÌáÊDZØÐëÀí½â±Õ°ü¡£±Õ°üµÄ´´½¨Ïà¶ÔÈÝÒ×£¬ÈËÃÇÉõÖÁ»áÔÚ²»¾­Òâ¼ä´´½¨±Õ°ü£¬µ«ÕâЩÎÞÒâ´´½¨µÄ±Õ°üÈ´´æÔÚDZÔÚµÄΣº¦£¬ÓÈÆäÊÇÔڱȽϳ£¼ûµÄä¯ÀÀÆ÷»·¾³Ï¡£Èç¹ûÏëÒªÑﳤ±Ü¶ÌµØʹÓñհüÕâÒ»ÌØÐÔ£¬Ôò±ØÐëÁ˽âËüÃǵŤ×÷»úÖÆ¡£¶ø±Õ°ü¹¤×÷»úÖƵÄʵÏֺܴó³Ì¶ÈÉÏÓÐÀµÓÚ±êʶ·û£¨»òÕß˵¶ÔÏóÊôÐÔ£©½âÎö¹ý³ÌÖÐ×÷ÓÃÓòµÄ½ÇÉ«¡£
¹ØÓÚ±Õ°ü£¬×î¼òµ¥µÄÃèÊö¾ÍÊÇ ECMAScript ÔÊÐíʹÓÃÄÚ²¿º¯Êý£­£­¼´º¯Êý¶¨ÒåºÍº¯Êý±í´ïʽλÓÚÁíÒ»¸öº¯ÊýµÄº¯ÊýÌåÄÚ¡£¶øÇÒ£¬ÕâЩÄÚ²¿º¯Êý¿ÉÒÔ·ÃÎÊËüÃÇËùÔÚµÄÍⲿº¯ÊýÖÐÉùÃ÷µÄËùÓоֲ¿±äÁ¿¡¢²ÎÊýºÍÉùÃ÷µÄÆäËûÄÚ²¿º¯Êý¡£µ±ÆäÖÐÒ»¸öÕâÑùµÄÄÚ²¿º¯ÊýÔÚ°üº¬ËüÃǵÄÍⲿº¯ÊýÖ®Íâ±»µ÷ÓÃʱ£¬¾Í»áÐγɱհü¡£Ò²¾ÍÊÇ˵£¬ÄÚ²¿º¯Êý»áÔÚÍⲿº¯Êý·µ»Øºó±»Ö´ÐС£¶øµ±Õâ¸öÄÚ²¿º¯ÊýÖ´ÐÐʱ£¬ËüÈÔÈ»±ØÐè·ÃÎÊÆäÍⲿº¯ÊýµÄ¾Ö²¿±äÁ¿¡¢²ÎÊýÒÔ¼°ÆäËûÄÚ²¿º¯Êý¡£ÕâЩ¾Ö²¿±äÁ¿¡¢²ÎÊýºÍº¯ÊýÉùÃ÷£¨×î³õʱ£©µÄÖµÊÇÍⲿº¯Êý·µ»ØʱµÄÖµ£¬µ«Ò²»áÊܵ½ÄÚ²¿º¯ÊýµÄÓ°Ïì¡£
Òź¶µÄÊÇ£¬ÒªÊʵ±µØÀí½â±Õ°ü¾Í±ØÐëÀí½â±Õ°ü±³ºóÔËÐеĻúÖÆ£¬ÒÔ¼°Ðí¶àÏà¹ØµÄ¼¼Êõϸ½Ú¡£ËäÈ»±¾ÎĵÄÇ°°ë²¿·Ö²¢Ã»ÓÐÉæ¼° ECMA 262 ¹æ·¶Ö¸¶¨µÄijЩËã·¨£¬µ«ÈÔÈ»ÓÐÐí¶àÎÞ·¨»Ø±Ü»ò¼ò»¯µÄÄÚÈÝ¡£¶ÔÓÚ¸ö±ðÊìϤ¶ÔÏóÊôÐÔÃû½âÎöµÄÈËÀ´Ëµ£¬¿ÉÒÔÌø¹ýÏà¹ØµÄÄÚÈÝ£¬µ«Êdzý·ÇÄã¶Ô±Õ°üÒ²·Ç³£ÊìϤ£¬·ñÔò×îºÃÊDz»ÒªÌø¹ýÏÂÃ漸½Ú¡£
¶ÔÏóÊôÐÔÃû½âÎö
ECMAScript ÈÏ¿ÉÁ½Àà¶ÔÏó£ºÔ­Éú£¨Native£©¶ÔÏóºÍËÞÖ÷£¨Host£©¶ÔÏó£¬ÆäÖÐËÞÖ÷¶ÔÏó°üº¬Ò»¸ö±»³ÆΪÄÚÖöÔÏóµÄÔ­Éú¶ÔÏóµÄ×ÓÀࣨECMA 262 3rd Ed Section 4.3£©¡£Ô­Éú¶ÔÏóÊôÓÚÓïÑÔ£¬¶øËÞÖ÷¶ÔÏóÓÉ»·¾³Ìṩ£¬±ÈÈç˵¿ÉÄÜÊÇÎĵµ¶ÔÏó¡¢DOM µÈÀàËƵĶÔÏó¡£
Ô­Éú¶ÔÏó¾ßÓÐËÉÉ¢ºÍ¶¯Ì¬µÄÃüÃûÊôÐÔ£¨¶ÔÓÚijЩʵÏÖµÄÄÚÖ


Ïà¹ØÎĵµ£º

javascriptЧÂʾ­Ñé̸(Ò»)

±¾ÎÄÖ÷ÒªÊdzöÓÚÓÐÅóÓÑʹÓÃÎÒÔ­À´Ð´µÄautocompleteµÄJS¿Ø¼þ¡£µ±Êý¾ÝÁ¿´óµÄʱºò£¬»á³öÏÖЧÂʼ«ÆäÂýµÄÇé¿ö£¬ÎÒÔÚÕâ¶Îʱ¼ä×ö³öµÄһЩ²âÊÔÒ²¼°Ò»Ð©¾­Ñ飬Óë´ó¼Ò·ÖÏí£¬Èç¹ûÓдíµÄµØ·½£¬»¹ÇëÖ¸³ö¡£
¾­¹ý²âÊÔ£¬ÎÒÃǻᷢÏÖÈçϵÄÇé¿ö»òÕß˵µÄ½áÂÛ£¬Èç¹ûÄúµÄ²âÊÔ½á¹ûÓëÎҵIJ»·û£¬Çë˵Ã÷Ô­Òò£¬ÒÔ±ãÏ໥ѧϰ¡£
1£©µ±Ò»¸ö½Ï´óµÄHTML×Ö· ......

[ת]JavaScriptÖеÄtrimº¯Êý

/**
* È¥³ý¶àÓà¿Õ¸ñº¯Êý
* trim:È¥³ýÁ½±ß¿Õ¸ñ lTrim:È¥³ý×ó¿Õ¸ñ rTrim: È¥³ýÓÒ¿Õ¸ñ
* Ó÷¨£º
*     var str = "  hello ";
*     str = str.trim();
*/
String.prototype.trim = function()
{
    return this.replace(/(^[\\s]*)|([\\s]*$)/g, ""); ......

JavaScriptÊäÈë¿ò

<input type="text" onblur="if (value ==''){value='ÇëÊäÈë¹Ø¼ü×Ö'}" onfocus="if (value =='ÇëÊäÈë¹Ø¼ü×Ö'){value =''}" id="q" name="q" value="ÇëÊäÈë¹Ø¼ü×Ö" style="width: 100px; height: 14px;">
......

JavaScriptÓëDropDownList

´ó¼Ò¶¼ÖªµÀ£¬.NETÖÐһЩWeb·þÎñÆ÷¿Ø¼þ½âÎö²¢±àÒ룬×îÖÕ±»äÖȾµÄʱºò£¬ÆäʵÊÇת»¯³ÉÁËÆÕͨµÄhtml¿Ø¼þ£¬±ÈÈç<asp:LinkButton>¿Ø¼þ¾Í±»äÖȾ³ÉÁË<a>êµã¿Ø¼þ£¬ÕâÀïÒª½²µÄDropDownList¿Ø¼þÒ²Ò»Ñù£¬±»äÖȾ³ÉÁËÆÕͨµÄselect¿Ø¼þ£¬ÔÚÈçϵÄasp.netÒ³ÃæÖж¨ÒåÁËÒ»¸öweb·þÎñÆ÷¿Ø¼þDropDownListºÍÒ»¸öÆÕͨµÄselect¿Ø¼þ£¨Ö÷ ......

TEXTAREA ×Ö½ÚÏÞÖÆ(javascript£¬struts µÄÒ³Ãæ±êÇ©)

//Textarea maxlength
//flag:text¿òÃû×Ö£¬num:ÏÞÖƵÄ×Ö½ÚÊý
  function maxLen(flag,num){
  if(document.getElementById('lastMessage').value=="0" || document.getElementById('lastMessage').value==flag){
    var i=document.getElementById(flag).value.replace(/[\u0 ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ