¡¶Îò͸javascript¡·Ñ§Ï°±Ê¼Ç£ºÁù¡¢·Å϶ÔÏó
ÒýÑÔ
ÔÙÀ´¿´¿´functionÓëobjectµÄ³¬È»½áºÏ°É¡£
ÔÚÃæÏò¶ÔÏóµÄ±à³ÌÊÀ½çÀÊý¾ÝÓë´úÂëµÄÓлú½áºÏ¾Í¹¹³ÉÁ˶ÔÏóµÄ¸ÅÄî¡£×Ô´ÓÓÐÁ˶ÔÏ󣬱à³ÌÊÀ½ç¾Í±»»®·Ö³ÉÁ½²¿·Ö£¬Ò»¸öÊǶÔÏóÄÚµÄÊÀ½ç£¬Ò»¸öÊǶÔÏóÍâµÄÊÀ½ç¡£¶ÔÏóÌìÉú¾ßÓÐ×Ô˽µÄÒ»Ã棬ÍâÃæµÄÊÀ½çδ¾ÔÊÐíÊDz»¿É·ÃÎʶÔÏóÄÚ²¿µÄ¡£¶ÔÏóÒ²Óд󷽵ÄÒ»Ã棬Ëü¶ÔÍâÌṩÊôÐԺͷ½·¨£¬Ò²ÎªËûÈË·þÎñ¡£²»¹ý£¬ÔÚÕâÀïÎÒÃÇҪ̸µ½Ò»¸öÓÐȤµÄÎÊÌ⣬¾ÍÊÇ“¶ÔÏóµÄ×ÔÎÒÒâʶ”¡£
Àí½âthis
JavaScriptÖÐÒ²ÓÐthis£¬µ«Õâ¸öthisÈ´ÓëC++¡¢C#»òJavaµÈÓïÑÔµÄthis²»Í¬¡£Ò»°ã±à³ÌÓïÑÔµÄthis ¾ÍÊǶÔÏó×Ô¼º£¬¶ø JavaScript µÄ this È´²¢²»Ò»¶¨£¡this ¿ÉÄÜÊÇÎÒ£¬Ò²¿ÉÄÜÊÇÄ㣬¿ÉÄÜÊÇËû£¬·´ÕýÊÇÎÒÖÐÓÐÄ㣬ÄãÖÐÓÐÎÒ£¬Õâ¾Í²»ÄÜÓÃÔÀ´µÄÄǸö“×ÔÎÒ”À´Àí½â JavaScriptÕâ¸öthisµÄº¬ÒåÁË¡£Îª´Ë£¬ÎÒÃDZØÐëÊ×ÏÈ·ÅÏÂÔÀ´¶ÔÏóµÄÄǸö“×ÔÎÒ”¡£
<script language="javascript">
function WhoAmI(){
//´ËʱÊÇ this µ±Ç°Õâ¶Î´úÂëµÄÈ«¾Ö¶ÔÏó£¬ÔÚä¯ÀÀÆ÷ÖоÍÊÇwindow ¶ÔÏó£¬ÆänameÊôÐÔΪ¿Õ×Ö·û´®¡£Êä³ö£ºI'm of object
alert("i'm " + this.name + " of " + typeof(this));
alert("url is " + this.location); //Ö¤Ã÷´ËʱµÄthisÊÇwindow¶ÔÏó
}
WhoAmI(); //Ö´ÐÐ
var Bill = {name:"BillGates"}; //´´½¨Ò»¸ö¶ÔÏó
Bill.WhoAmI = WhoAmI; //ΪBillÔö¼ÓÒ»¸öWhoAmIµÄ·½·¨£¬²¢¸³ÎªÉÏÃæµÄ·½·¨
Bill.WhoAmI(); //Ö´ÐÐ, ´ËʱthisÊÇBill
WhoAmI.call(Bill); //Ö´ÐУ¬ ´ËʱthisÊÇBill
({name:"noName", WhoAmI:WhoAmI}).WhoAmI();
</script>
ÔÚJavaScriptº¯ÊýÖУ¬ÄãÖ»ÄÜ°Ñthis¿´³Éµ±Ç°Òª·þÎñµÄ“Õâ¸ö”¶ÔÏó¡£thisÊÇÒ»¸öÌØÊâµÄÄÚÖòÎÊý£¬¸ù¾Ýthis²ÎÊý£¬Äú¿ÉÒÔ·ÃÎʵ½“Õâ¸ö”¶ÔÏóµÄÊôÐԺͷ½·¨£¬µ«È´²»Äܸøthis²ÎÊý¸³Öµ¡£ÔÚÒ»°ã¶ÔÏóÓïÑÔÖУ¬·½·¨Ìå´úÂëÖеÄthis¿ÉÒÔÊ¡ÂԵģ¬³ÉԱĬÈ϶¼Ê×ÏÈÊÇ“×Ô¼º”µÄ¡£µ«JavaScriptÈ´²»Í¬£¬ÓÉÓÚ²»´æÔÚ“×ÔÎÒ”£¬µ±·ÃÎÊ“Õâ¸ö”¶ÔÏóʱ£¬this²»¿ÉÊ¡ÂÔ£¡£¨Õâ¶Î»°ºÜ³éÏó£©
ÉÏÃæÑÝʾÁ˶àÖÖthisµÄ´«µÝ·½·¨£¬JavaScriptÌṩÁË´«µÝthis²Î
Ïà¹ØÎĵµ£º
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<TITLE>FLYSO Blog-- JS´úÂëʵÏÖµÄ×Ô¶¯·ÖҳЧ¹û~!</TITLE>
<META NAME="Generator" CONTENT="EditPlus">
<META NAME="Author" CONTENT=""& ......
ÔÚJavascriptÖÐûÓÐclassÀ࣬µ«ÊÇͬÑùÒ²¿ÉÒÔ½øÐжÔÏóµÄ´´½¨¡£ÔÚÃæÏò¶ÔÏóµÄÓïÑÔÖÐÐèҪʵÀý»¯Ä³¸ö¾ßÌåÀàµÄʵÀý£¬ÔÚJavascriptÖÐÔò²»Óá£
ÔÚJavascriptÀ¶ÔÏñ¿ÉÒÔ´´½¨ÐµĶÔÏó£¬Ò²¿ÉÒԼ̳Ð×ÔÆäËû¶ÔÏó¡£Õâ¸ö¸ÅÄî³ÆΪÔÐÍ»¯¼Ì³Ð(prototypal inheritance)¡£
Èκκ¯ÊýÔÚJavascript Öж¼¿ÉÒÔ±»ÊµÀý»¯Ò»¸ö¶ÔÏó¡£
³ÌÐòÈçÏ£º
// ......
Thickbox
-
»ùÓÚ
jQuery
£¬Ö§³Ö AJAX£¬ÇáÁ¿¼¶µÄ¶øÇұȽϸßЧ¡£Ö§³ÖͼƬÓëHTMLÄÚÈÝ¡£´óСԼΪ
40k£¬Ä¿Ç°»¹¿É×÷Ϊ WordPress
µÄ²å¼þʹÓá£Õâ¸öjsµÄÓŵãÔÚÓÚÓ룬¸¸¼¶µÄÔÒ³Ãæ¹ö¶¯ÌõËæÊó±ê¹ö¶¯µÄʱºò£¬µ¯³öµÄ²ã²¢²»Òƶ¯£¬¶øʼÖÕ´¦ÓÚä¯ÀÀÆ÷µÄ¹Ì¶¨Î»Öá£
GreyBox
- ´´½¨ iframe µÄµ¯³ö½çÃ棬¿ÉʹÓÃͼƬ ......
Java,JavaScript,JScript Çø±ð
ÕâÈý¸öÓïÑÔ·Ö±ðÊÇÈý¸ö¹«Ë¾¿ª·¢µÄ£¬SUNµÄJava£¬NetscapeµÄJavaScript£¬MicrosoftµÄJScript
JavaScriptÊÇÓÉNetscape¹«Ë¾¿ª·¢²¢ËæNavigatorµ¼º½ÕßÒ»Æð·¢²¼µÄ¡¢½éÓÚJavaÓëHTMLÖ®¼ä¡¢»ùÓÚ¶ÔÏóʼþÇý¶¯µÄ±à³ÌÓïÑÔ£¬²»ÐèÒªJava±àÒëÆ÷£¬¶øÊÇÖ±½ÓÔËÐÐÔÚWebä¯ÀÀÆ÷ÖУ¬ËüµÄÇ°ÉíÊÇLive Script¡£
JScr ......
ÒýÑÔ
ÒªÀí½â JavaScript£¬ÄãµÃÊ×ÏÈ·Å϶ÔÏóºÍÀàµÄ¸ÅÄ»Øµ½Êý¾ÝºÍ´úÂëµÄ±¾Ô¡£Ç°Ãæ˵¹ý£¬±à³ÌÊÀ½çÖ»ÓÐÊý¾ÝºÍ´úÂëÁ½ÖÖ»ù±¾ÔªËØ£¬¶øÕâÁ½ÖÖÔªËØÓÖÓÐמÀ²ø²»ÇåµÄ¹Øϵ¡£JavaScript¾ÍÊÇ°ÑÊý¾ÝºÍ´úÂ붼¼ò»¯µ½×îÔʼµÄ³Ì¶È¡£
»ù±¾ÀàÐÍ
Ò»¡¢¼òµ¥Êý¾ÝÀàÐÍ£ºundefined¡¢null¡¢boolean¡¢number¡¢string£¨×¢Ò⣺¶¼Ê ......