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

JavaScript×îÈÃÈ˷ѽâµÄÊ®¼þÊÂ(

Ô­ÎĵØÖ·£ºhttp://developer.51cto.com/art/201002/185161.htm
JavaScriptÊÇÒ»Öֹ㷺ÓÃÓÚ¿Í»§¶ËWeb¿ª·¢µÄ½Å±¾ÓïÑÔ£¬Æä¿ÉËãÊÇÊÀ½çÉÏ×îÁ÷Ðеıà³ÌÓïÑÔ£¬ËüÔø±»Web¿ª·¢Éè¼ÆʦÌùÉÏجÃεıêÇ©£¬ËäÈ»ÕæÕýµÄجÃÎÆäʵÊÇDOM API£¬Ò²Ôø¾­ÓÐÈËÈÏΪJavaScriptÓï·¨ÖÐÓкܶàÏÝÚ壬ͬʱÆäÒ²ÓкܶàÈÃÈ˷ѽâµÄ¶«Î÷¡£
1. ËüÒÔJavaÃüÃû£¬µ«²¢²»ÊÇJava
Ëü×î³õ½ÐMocha£¬ ½ÓןÄÃûΪ LiveScript£¬×îºó²ÅÈ·¶¨ÃüÃûΪJavaScript£¬¸ù¾ÝÀúÊ·¼Ç¼£¬Java µÄÃüÃûÓë Netscape ºÍ Sun Ö®¼äµÄºÏ×÷Óйأ¬×÷Ϊ½»»»Ìõ¼þ£¬Netscape ÔÚËûÃDZ¸ÊÜ»¶Ó­µÄä¯ÀÀÆ÷Öд´½¨ÁË Java ÔËÐÐʱ¡£ÖµµÃÒ»ÌáµÄÊÇ£¬Õâ¸öÃû×ֵijǫ̈¼¸½üÒ»¸öÍæЦ£¬ÒªÖªµÀ£¬LiveScript ºÍ Java ÔÚ¿Í»§¶Ë½Å±¾·½Ãæ´æÔڵжԹØϵ£¬²»¹ÜÔõô˵£¬ÈËÃǺóÀ´²»µÃ²»Ò»ÔÙ³ÎÇåµÄÒ»¼þʾÍÊÇ£¬JavaScript ºÍ Java ºÁÎÞ¹Øϵ¡£
2. Null ÊǸö¶ÔÏó£¿
¿´¿´Õâ¶Î´úÂ룬Ëü·µ»ØµÄÊÇobject¡£
ÕâʵÔÚÁîÈ˷ѽ⣬¼ÙÈç null ±íʾ¿ÕÖµ£¬ËüÔõô¿ÉÒÔÊǶÔÏ󣿼òµ¥Ëµ£¬ËüÊÇJavaScript ×î³õ°æ±¾µÄ´íÎó£¬Õâ¸ö´íÎóÉõÖÁ±»Î¢ÈíµÄ JScript Ö±½Ó½èÓá£
3. NaN !== NaN
NaN£¬±íʾһ¸ö·ÇÊý×ÖµÄÖµ£¬È»¶øÎÊÌâÊÇ£¬NaN²»µÈÓÚÈκζ«Î÷£¬ÉõÖÁ²»µÈÓÚËü×Ô¼º¡£
ÕâÏÔÈ»²»¶Ô£¬ÊÂʵÉÏ£¬Èç¹ûÒªÅжÏÒ»¸öֵȷʵÊÇ NaN£¬ÄãÐèÒªÓà isNaN() º¯Êý¡£
4. È«¾Ö±äÁ¿
¶ÔÈ«¾Ö±äÁ¿µÄÒÀÀµÒ»Ö±±»ÊÓΪ JavaScript ×µÄ²¿·Ö£¨ECMA µÄ JavaScript 5 ÒѾ­È¥µôÁËÈ«¾Ö±äÁ¿£¬Çë²ÎÔÄ ECMA ÍƳö JavaScript 5 - ÒëÕß×¢£©¡£¶Ô¼òµ¥µÄÒ³Ã棬ÕâÎÞËùν£¬µ«¸´ÔÓµÄÒ³Ã棬Èç¹û°üº¬´óÁ¿ JavaScript ½Å±¾£¬ÄãºÜÄÑÖªµÀij¸öÈ«¾Ö±äÁ¿ÊÇÔÚÄÄÀïÉùÃ÷µÄ£¬Èç¹û¼¸¸öÈ«¾Ö±äÁ¿²»Ð¡ÐÄÖØÃû£¬¾Í»áÒý·¢´íÎó¡£
5. ÄÇЩͳͳ±»Ì½²âΪMozilla User-Agent µÄä¯ÀÀÆ÷
±ØÐë³ÐÈÏ£¬ÊÂʵÉÏ£¬Õâ²»ÊÇJavaScript µÄ´í£¬ÊǸ÷¸öä¯ÀÀÆ÷ÓÐÒâΪ֮¡£±ÈÈ磬ÒÔÏÂÊÇÓÃJavaScript ̽²âSafari ʱµÃµ½µÄ½á¹û£º
ÊÇ·ñ×¢Òâµ½ÆäÖеĵÚÒ»¸öµ¥´Ê Mozilla/5.0£¬ÎªÊ²Ã´ Safari »á±»Ì½²âΪ Mozilla£¬¾¡¹Ü Safari ºóÀ´ÒѾ­¾ÀÕýÕâÒ»ÎÊÌ⣬µ«ÈÔÈ»²»ÄܽâÊÍΪʲôËüÃÇÒªÕâÑùÎ󵼿ª·¢Õß¡£ÊÂʵÉÏ£¬Äã»á·¢ÏÖ£¬¾ø´ó¶àÊýä¯ÀÀÆ÷°ÑËûÃÇµÄ User Agent ÉèÖÃΪ Mozilla£¬´ð°¸Òª»Øµ½10ÄêÇ°£¬Õâ¸ü¶àÊÇÒ»ÖÖ²ßÂÔ¡£User Agent ÊÇÒ»¶ÎÓÃÀ´±êʶµ±Ç°ä¯ÀÀÆ÷Éí·ÝµÄ×Ö·û´®£¬ÊÀ½çÉϵÚÒ»¸öä¯ÀÀÆ÷Mosaic£¬ÔøÕâÑù±êÖ¾×Ô¼º£º
ÕâºÜºÏÀí£¬Òò´Ëµ± Netscape ³öÀ´µÄʱºò£¬Ëü±£ÁôÁËMosaicÕâ¸ö´«Í³£¬»¹ÔÚºóÃæÌí¼ÓÁËÒ»¸ö¼ÓÃÜ·½Ê½²¿·Ö¡£
µ½Ä¿Ç°ÎªÖ¹£¬Ò»Çа²ºÃ£¬Ö±µ½ IE3 ·¢²¼£¬µ± IE3 ·¢²¼µÄʱºò£¬Ne


Ïà¹ØÎĵµ£º

¡¶Îò͸javascript¡·Ñ§Ï°±Ê¼Ç£ºÈý¡¢ËÆÀàÈ´²»ÊÇÀà

ÒýÑÔ
 
JavaScriptûÓÐ “Àà”µÄ¸ÅÄÕâÈúܶàѧϰ¹ý¸ß¼¶ÓïÑÔµÄÈ˸е½ºÜ²»Ë¬£¬Æäʵ±ÈÖ®ÓÚCÓïÑÔÓÖÈçºÎÄØ£¿ÏÔÈ»JavaScriptÒª±ÈCÓïÑÔºÃÓúܶࡣ
 
²»·Ï»°£¬ÉÏ´úÂë
 
<script language="javascript">
/*Ò»¾ä¾äµÄ¿´¸üÈÝÒ×Ã÷°×*/
//ÉùÃ÷Ò»¸ö¶ÔÏ󣬵«Ëüʲô¶¼Ã»ÓÐ
var life = {};
//ÈÎ ......

¡¶Îò͸javascript¡·Ñ§Ï°±Ê¼Ç£ºÁù¡¢·Å϶ÔÏó

ÒýÑÔ
 
ÔÙÀ´¿´¿´functionÓëobjectµÄ³¬È»½áºÏ°É¡£
 
    ÔÚÃæÏò¶ÔÏóµÄ±à³ÌÊÀ½çÀÊý¾ÝÓë´úÂëµÄÓлú½áºÏ¾Í¹¹³ÉÁ˶ÔÏóµÄ¸ÅÄî¡£×Ô´ÓÓÐÁ˶ÔÏ󣬱à³ÌÊÀ½ç¾Í±»»®·Ö³ÉÁ½²¿·Ö£¬Ò»¸öÊǶÔÏóÄÚµÄÊÀ½ç£¬Ò»¸öÊǶÔÏóÍâµÄÊÀ½ç¡£¶ÔÏóÌìÉú¾ßÓÐ×Ô˽µÄÒ»Ã棬ÍâÃæµÄÊÀ½çδ¾­ÔÊÐíÊDz»¿É·ÃÎʶÔÏóÄÚ²¿µÄ¡£¶ÔÏóÒ²Óдó ......

¡¶Îò͸javascript¡·Ñ§Ï°±Ê¼Ç£º¾Å¡¢Ô­Ðͱ϶

ÒýÑÔ
 
      prototypeÔ´×Ô·¨ÓÈí¼þ½çµÄ±ê×¼·­ÒëΪ“Ô­ÐÍ”£¬´ú±íÊÂÎïµÄ³õʼÐÎ̬£¬Ò²º¬ÓÐÄ£ÐͺÍÑù°åµÄÒâÒå¡£
 
prototypeÊôÐÔ
 
JavaScriptµÄËùÓÐfunctionÀàÐ͵ĶÔÏó¶¼ÓÐÒ»¸öprototypeÊôÐÔ¡£Õâ¸öprototypeÊôÐÔ±¾ÉíÓÖÊÇÒ»¸ö object ÀàÐ͵ĶÔÏó£¬Òò´ËÎÒÃÇÒ²¿ÉÒÔ¸ ......

javascript¼¼ÇÉ×Öµä

ÿһÏÊÇjsÖеÄС¼¼ÇÉ£¬µ«Ê®·ÖµÄʵÓã¡
1.document.write(""); Êä³öÓï¾ä
2.JSÖеÄ×¢ÊÍΪ//
3.´«Í³µÄHTMLÎĵµË³ÐòÊÇ:document->html->(head,body)
4.Ò»¸öä¯ÀÀÆ÷´°¿ÚÖеÄDOM˳ÐòÊÇ:window->(navigator,screen,history,location,document)
5.µÃµ½±íµ¥ÖÐÔªËصÄÃû³ÆºÍÖµ:document.getElementById("±íµ¥ÖÐÔªËØµÄ ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ