Ò׽ؽØͼÈí¼þ¡¢µ¥Îļþ¡¢Ãâ°²×°¡¢´¿ÂÌÉ«¡¢½ö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]¶àÐÐTextBox»Ø³µ»»ÐУ¬¹â±êÒƵ½×îĩβ

Ò³ÃæÆÁ±ÎÁ˻سµ£¬½á¹û¶àÐÐÊäÈëµÄTextbox±¯¾çÁË£¬Ö»ÄÜÓÃjsÖØд»Ø³µÊ¼þ£¬±¸·ÝÒ»ÏÂ
pageloadÀï
 txt_eng.Attributes.Add("onkeypress", "enter(this)");
js£º
function enter(obj) {
            if (event.keyCode == 13) {
    &nb ......

JavaScriptÓëDropDownList

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

ÓÃjavaScriptÖÆ×÷ÍøÒ³ÖÐÏÔʾÁбí

µÚÒ»ÖÖ:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>ÎÞ±êÌâÎ ......

ÉîÈëÀí½âJavaScript±Õ°ü£¨closure£©

×î½üÔÚÍøÉϲéÔÄÁ˲»ÉÙJavascript±Õ°ü(closure)Ïà¹ØµÄ×ÊÁÏ£¬Ð´µÄ´ó¶àÊǷdz£µÄѧÊõºÍרҵ¡£¶ÔÓÚ³õѧÕßÀ´Ëµ±ð˵Àí½â±Õ°üÁË£¬¾ÍÁ¬ÎÄ×ÖÐðÊö¶¼ºÜÄÑ¿´¶®¡£×«Ð´´ËÎĵÄÄ¿µÄ¾ÍÊÇÓÃ×îͨË×µÄÎÄ×Ö½Ò¿ªJavascript±Õ°üµÄÕæʵÃæÄ¿¡£
Ò»¡¢Ê²Ã´ÊDZհü£¿
“¹Ù·½”µÄ½âÊÍÊÇ£ºËùν“±Õ°ü”£¬Ö¸µÄÊÇÒ»¸öÓµÓÐÐí¶à±äÁ¿ºÍ°ó¶¨Á ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ