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

JavaScriptÖеÄJSON

Ô­Ö·£ºhttp://www.dreamdu.com/blog/2008/10/19/json_in_javascript/
JavaScriptÖеÄJSON
×÷ÕߣºDouglas Crockford
Ô­ÎÄÍøÖ·£ºhttp://www.json.org/js.html
ÒëÕߣº¿É°®µÄºï×Ó
JavaScriptÕâÖÖ±à³ÌÓïÑÔÊ×ÒªµÄÄ¿µÄÊÇΪNetscape NavigatorÌṩһÖÖÒ³Ãæ½Å±¾ÓïÑÔ¡£ËüÈÔ±»ÆÕ±éµÄÈÏΪÊÇJavaµÄÒ»¸ö×Ó¼¯£¬µ«ÊÂʵ²¢·ÇÈç´Ë¡£ËüÊÇÒ»ÖÖÓï·¨ÀàËÆcÓïÑÔ²¢ÇÒÖ§³ÖÃæÏò¶ÔÏóµÄScheme-likeÓïÑÔ¡£JavaScriptʹÓÃÁËECMAScriptÓïÑԹ淶µÚÈý°æ½øÐÐÁ˱ê×¼»¯¡£
JSONÊÇJavaScriptÃæÏò¶ÔÏóÓï·¨µÄÒ»¸ö×Ó¼¯¡£ÓÉÓÚJSONÊÇJavaScriptµÄÒ»¸ö×Ó¼¯£¬Òò´ËËü¿ÉÇåÎúµÄÔËÓÃÓÚ´ËÓïÑÔÖС£
var myJSONObject = {"bindings": [
{"ircEvent": "PRIVMSG", "method": "newURI", "regex": "^http://.*"},
{"ircEvent": "PRIVMSG", "method": "deleteURI", "regex": "^delete.*"},
{"ircEvent": "PRIVMSG", "method": "randomURI", "regex": "^random.*"}
]
};
ÉÏÃæµÄʾÀý£¬´´½¨ÁËÒ»¸ö°üÀ¨µ¥¶À³ÉÔ±”bindings”µÄ¶ÔÏ󣬴˳ÉÔ±°üÀ¨Ò»¸öº¬ÓÐÈý¸ö¶ÔÏ󣨔ircEvent”, “method”, Óë “regex”£©µÄÊý×é
³ÉÔ±¿ÉÒÔͨ¹ý.»òÕßϱê²Ù×÷·û¼ìË÷¡£
myJSONObject.bindings[0].method // "newURI"
ΪÁ˽«JSONÎı¾×ª»»Îª¶ÔÏ󣬿ÉÒÔʹÓÃeval()º¯Êý¡£eval()º¯Êýµ÷ÓÃJavaScript±à¼­Æ÷¡£ÓÉÓÚJSONÊÇJavaScriptµÄ×Ó¼¯£¬Òò´Ë±àÒëÆ÷½«ÕýÈ·µÄ½âÎöÎı¾²¢²úÉú¶ÔÏó½á¹¹¡£Îı¾±ØÐëÀ¨ÔÚÀ¨ºÅÖбÜÃâ²úÉúJavaScriptµÄÓï·¨ÆçÒå¡£
var myObject = eval('(' + myJSONtext + ')');
evalº¯Êý·Ç³£¿ìËÙ¡£Ëü¿ÉÒÔ±àÒëÖ´ÐÐÈκÎJavaScript³ÌÐò£¬Òò´Ë²úÉúÁË°²È«ÐÔÎÊÌâ¡£µ±Ê¹ÓÿÉÐÅÈÎÓëÍêÉƵÄÔ´´úÂëʱ²Å¿ÉÒÔʹÓÃevalº¯Êý¡£ÕâÑù¿ÉÒÔ¸ü°²È«µÄʹÓÃJSON½âÎöÆ÷¡£Ê¹ÓÃXMLHttpRequestµÄwebÓ¦Óã¬Ò³ÃæÖ®¼äµÄͨѶֻÔÊÐíͬԴ£¬Òò´ËÊÇ¿ÉÒÔÐÅÈεġ£µ«ÕâÈ´²»ÊÇÍêÉƵġ£Èç¹û·þÎñÆ÷ûÓÐÑϽ÷µÄJSON±àÂ룬»òÕßûÓÐÑϸñµÄÊäÈëÑéÖ¤£¬ÄÇô¿ÉÄÜ´«ËÍ°üÀ¨Î£Ïսű¾µÄÎÞЧJSONÎı¾¡£evalº¯Êý½«Ö´ÐжñÒâµÄ½Å±¾¡£
ʹÓÃJSON½âÎöÆ÷¿ÉÒÔ·ÀÖ¹´ËÀàʼþ¡£JSON½âÎöÆ÷Ö»ÄܱæʶJSONÎı¾£¬¾Ü¾øËùÓнű¾¡£ÌṩÁ˱¾µØJSONÖ§³ÖµÄä¯ÀÀÆ÷µÄJSON½âÎöÆ÷½«Ô¶¿ìÓÚevalº¯Êý¡£Ô¤¼ÆδÀ´µÄECMAScript±ê×¼½«Ö§³Ö±¾µØJSON¡£
var myObject = JSON.parse(myJSONtext, reviver);
Ò»¸öÌæ»»º¯Êý£¨reviver function£©×öΪ¿ÉÑ¡²ÎÊý±»×îÖÕ½á¹ûµÄÿһ¼¶µÄ¼ü£¨key£©ÓëÖµ£¨value£©µ÷Óᣠÿ¸öÖµ¶¼½«±»Ìæ»»º¯ÊýµÄÖµ´úÌæ¡


Ïà¹ØÎĵµ£º

JSP+JavaScript´òÔì¶þ¼¶¼¶ÁªÏÂÀ­²Ëµ¥

JSP+JavaScrip
t´òÔì¶þ¼¶¼¶ÁªÏÂÀ­²Ëµ¥£º
(¸öÈ˲©¿Í£ºwww.duduct.com)
class(Ò»¼¶À¸Ä¿ÐÅÏ¢£©£ºclassId(×Ô¶¯±àºÅ£©£¬className£¨À¸Ä¿Ãû³Æ£©,
Nclass£¨¶þ¼¶À¸Ä¿ÐÅÏ¢£©,
NclassId£¨×Ô¶¯±àºÅ£©£¬NclassName(À¸Ä¿Ãû³Æ£©£¬parentId£¨Ò»¼¶À¸Ä¿id£¬Óëclass±íÖеÄclassId¹ØÁª£©
......

[¾­Ñé×ܽá]½üÆÚJavaScript±à³Ì×ܽá


JavaScript
ת×Ô£º http://www.disandu.com/?p=603
============================================================================
1 ´¦ÀíXSLT  µ÷Óôø²ÎÊýµÄXSLTÄ£°åµÄ·½·¨ Ïê¼û 23Ìõ
  <html>
    <body>
       ......

javaScriptÕýÔò±í´ïʽ

Ò» javascriptÕýÔò±í´ïʽµÄ»ù±¾ÖªÊ¶
1     javascript ÕýÔò¶ÔÏó´´½¨ ºÍÓ÷¨
    ÉùÃ÷javascript ÕýÔò±í´ïʽ
   
     var reCat = new RegExp("cat");
      ÄãÒ²¿ÉÒÔ
     var reCat = /cat ......

ÓÃJavaScriptÐÞ¸ÄÍøÒ³cssÑùʽ

ÓÃJavaScriptÐÞ¸ÄÍøÒ³Ñùʽ
Ò»¡¢¾Ö²¿¸Ä±äÑùʽ
·ÖΪ¸Ä±äÖ±½ÓÑùʽ£¬¸Ä±äclassNameºÍ¸Ä±äcssTextÈýÖÖ¡£ÐèҪעÒâµÄÊÇ£º
×¢Òâ´óСд
£º
javascript¶Ô´óСдʮ·ÖÃô¸Ð£¬className²»Äܹ»°Ñ“N”д³É“n”£¬cssTextÒ²²»Äܹ»°Ñ“T”д³É“t”£¬·ñÔòÎÞ·¨ÊµÏÖЧ¹û¡£
µ÷Ó÷½·¨
£º
Èç¹û¸Ä ......

JavaScript Moduleģʽ(ÒëÎÄ)


JavaScript Module Pattern
£¨
JavaScript
Module
ģʽ£© 
À´Ô´£º
1.      
http://yuiblog.com/blog/2007/06/12/module-pattern/
2.      
http://yuiblog.com/blog/2006/06/01/global-domination/
 
È«¾Ö±äÁ¿ÊÇÓкܴóΣº¦µÄ¡£ÔÚ
YU ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ