ÄÇЩÏà¼ûºÞÍíµÄ JavaScript ¼¼ÇÉ
¸ÐлÈñÉÌÆóÒµCMSµÄͶµÝ
ÐÂÎÅÀ´Ô´:Smashing Magazine
JavaScript µÄ³É¹¦ÈÃÈ˽ò½òÀÖµÀ£¬Îª Web ÍøÒ³±àд JavaScript ´úÂëÒѾÊÇËùÓÐ Web Éè¼ÆʦµÄ»ù±¾¹¦£¬ÕâÃÅÓÐȤµÄÓïÑÔÔ̲Ø×ÅÐí¶à²»ÎªÈËÊìÖªµÄ¶«Î÷£¬¼´Ê¹¶àÄêµÄ JavaScript ³ÌÐòÔ±£¬Ò²Î´ÄÜÍêÈ«³Ô͸¡£±¾ÎÄ´Ó7¸ö·½Ãæ½²Êö JavaScript ÖÐÄÇЩÄã²»ºÜÊìÖªµ«·Ç³£ÊµÓõļ¼ÇÉ¡£
¼òÂÔÓï¾ä
JavaScript ¿ÉÒÔʹÓüòÂÔÓï¾ä¿ìËÙ´´½¨¶ÔÏóºÍÊý×飬±ÈÈçÏÂÃæµÄ´úÂ룺
¿ÉÒÔʹÓüòÂÔÓï¾äÈçÏ£º
¶ÔÏó car ¾Í´Ë´´½¨£¬²»¹ýÐèÒªÌرð×¢Ò⣬½áÊø»¨À¨ºÅÇ°Ò»¶¨²»Òª¼Ó ";" ·ñÔòÔÚ IE »áÓöµ½ºÜ´óÂé·³¡£
´´½¨Êý×éµÄ´«Í³·½·¨ÊÇ£º
ʹÓüòÂÔÓï¾äÔò£º
ÁíÒ»¸ö¿ÉÒÔʹÓüòÂÔÓï¾äµÄµØ·½ÊÇÌõ¼þÅжÏÓï¾ä£º
¿ÉÒÔ¼òÂÔΪ£º
JSON Êý¾Ý¸ñʽ
JSON ÊÇ "JavaScript Object Notation" µÄËõд£¬ÓÉ Douglas Crockford Éè¼Æ£¬JSON ¸Ä±äÁË JavaScript ÔÚ»º´æ¸´ÔÓÊý¾Ý¸ñʽ·½ÃæµÄÀ§¾³£¬ÈçÏÂÀý£¬¼ÙÈçÄãÒªÃèÊöÒ»¸öÀÖ¶Ó£¬¿ÉÒÔÕâÑùд£º
Äã¿ÉÒÔÔÚ JavaScript ÖÐÖ±½ÓʹÓà JSON£¬ÉõÖÁ×÷ΪijЩ API µÄ·µ»ØÊý¾Ý¶ÔÏó£¬ÒÔÏ´úÂëµ÷ÓÃÖøÃûÊéÇ©ÍøÕ¾ delicious.com µÄÒ»¸ö API£¬·µ»ØÄãÔÚ¸ÃÍøÕ¾µÄËùÓÐÊéÇ©£¬²¢ÏÔʾÔÚÄã×Ô¼ºµÄÍøÕ¾£º
JavaScript ±¾µØº¯Êý (Math, Array ºÍ String)
JavaScript ÓкܶàÄÚÖú¯Êý£¬ÓÐЧµÄʹÓ㬿ÉÒÔ±ÜÃâºÜ¶à²»±ØÒªµÄ´úÂ룬±ÈÈ磬´ÓÒ»¸öÊý×éÖÐÕÒ³ö×î´óÖµ£¬´«Í³µÄ·½·¨ÊÇ£º
ʹÓÃÄÚÖú¯Êý¿ÉÒÔ¸üÈÝÒ×ʵÏÖ£º
ÁíÒ»¸ö·½·¨ÊÇʹÓà Math.max() ·½·¨£º
Äã¿ÉÒÔÓÃÕâ¸ö·½·¨°ïÖú̽²âä¯ÀÀÆ÷
Õâ½â¾öÁË IE ä¯ÀÀÆ÷µÄÒ»¸öÎÊÌ⣬ͨ¹ýÕâÖÖ·½·¨£¬Äã×ÜÊÇ¿ÉÒÔÕÒµ½ÄǸöÕýÈ·µÄÖµ£¬ÒòΪä¯ÀÀÆ÷²»Ö§³ÖµÄÄǸöÖµ»á·µ»Ø undefined¡£
»¹¿ÉÒÔʹÓà JavaScript ÄÚÖÃµÄ split() ºÍ join() º¯Êý´¦Àí HTML ¶ÔÏóµÄ CSS ÀàÃû£¬Èç¹û HTML ¶ÔÏóµÄÀàÃûÊÇ¿Õ¸ñ¸ô¿ªµÄ¶à¸öÃû×Ö£¬ÄãÔÚΪËü×·¼Ó»òɾ³ýÒ»¸ö CSS ÀàÃûµÄʱºòÐèÒªÌرð×¢Ò⣬Èç¹û¸Ã¶ÔÏó»¹Ã»ÓÐÀàÃûÊôÐÔ£¬¿ÉÒÔÖ±½Ó½«ÐµÄÀàÃû¸³ÓèËü£¬Èç¹ûÒѾ´æÔÚÀàÃû£¬ÐÂÔöµÄÀàÃûÇ°±ØÐëÓÐÒ»¸ö¿Õ¸ñ£¬Óô«Í³µÄ JavaScript ·½·¨ÊÇÕâÑùʵÏֵģº
ʹÓà split ºÍ join ·½·¨ÔòÖ±¹ÛÓÅÑŵöࣺ
ʼþ´úÀí
ÓëÆäÔÚ HTML ÎĵµÖÐÉè¼ÆÒ»¶Ñʼþ£¬²»ÈçÖ±½ÓÉè¼ÆÒ»¸öʼþ´úÀí£¬¾ÙÀý˵Ã÷£¬¼ÙÈçÄãÓÐһЩÁ´½Ó£¬Óû§µã»÷ºó²»Ïë´ò¿ªÁ´½Ó£¬¶øÊÇÖ´ÐÐij¸öʼþ£¬HTML ´úÂëÈçÏ£º
´«Í³µÄʼþ´¦ÀíÊDZéÀú¸÷¸öÁ´½Ó£¬¼ÓÉϸ÷×ÔµÄʼþ´¦Àí£º
ʹÓÃʼþ´úÀí£¬¿ÉÒÔÖ±½Ó´¦Àí£¬ÎÞÐè±éÀú£º
ÄäÃûº¯ÊýÓë Module ģʽ
JavaScript µÄÒ»¸öÎÊÌâÊÇ£¬ÈκαäÁ¿£¬º¯Êý»òÊǶÔÏ󣬳ý·ÇÊÇÔÚij
Ïà¹ØÎĵµ£º
ShowModalDialogº¯ÊýµÄ¹¦ÄÜ£º
´ò¿ªÒ»¸ö×Ó´°¿Ú£¬²¢ÇÒ¿ÉÓ븸´°¿ÚÏ໥´«µÝÊý¾Ý£¬ËüÓëwindow.openµÄ×î´óÇø±ð¾ÍÔÚÓÚÓÉShowModalDialog´ò¿ª×Ó´°¿Úºó£¬¸¸´°¿Ú½«²»ÄܲÙ×÷¡£
ʹÓ÷½·¨£º
vReturnValue = window.showModalDialog(sURL [, vArguments] [, sFeatures])
²ÎÊý˵Ã÷£º
sURL
±ØÑ¡²ÎÊý£¬ÀàÐÍ£º×Ö·û´®¡£ÓÃÀ´Ö¸¶¨¶Ô»°¿òÒªÏ ......
½ñÌìÔÚ×öJAVASCRIPTµÄʱºò,·¢ÏÖÀÏÊdzöÏ֔δ½áÊøµÄ×Ö·û´®³£Á¿”.
×Ô¼ºÕÒÁËÏÂÓ¦¸ÃÊÇ´«²ÎÊýµÄʱºò,ÓÐÌØÊâ×Ö·ûÒýÆðµÄ.ÍøÉÏÒ²ÕÒÁËÏÂ,Ò²Óкöà³öÏÖÕâÖÖÇé¿ö.×öÏÂ×ܽá,ÒÔ·½±ãÒÔºó²éÔÄ.
1.JAVASCRIPTÒýÓÃʱ,ʹÓõÄ×Ö·ûÓïÑÔ²»Ò»ÖÂ.
±ÈÈç:<script type=”text/javascript” src=”xxx.js” char ......
css,javascriptµÄÔ¤¼ÓÔØ
ΪÁËÌá¸ßÍøÕ¾µÄ¼ÓÔØËٶȣ¬ÓÐÒ»¸öºÜÖØÒªµÄÊֶξÍÊÇÔÚÓû§ä¯ÀÀ¹ý³ÌÖеÄÉÏÓÎÍøÕ¾×öÒ»¸öÎļþµÄÔ¤¼ÓÔØ¡£Ô¤¼ÓÔØÎļþÒ»°ãÓÐÁ½ÖÖ³£Óõķ½Ê½£ºxhrºÍ¶¯Ì¬²åÈë½ÚµãµÄ·½Ê½¡£¶¯Ì¬²åÈë½ÚµãÊÇ×îΪ¼òµ¥Ò²×îΪ¹ã·ºµÄÒ»ÖÖÒì²½¼ÓÔØ·½Ê½(ÀýÈçyuiµÄGetÄ£¿é)£¬È»ºóʹÓö¯Ì¬²åÈë½Úµã·½·¨¼ÓÔصÄÎļþ¶¼»áÔÚ¼ÓÔغóÁ¢¼´Ö´ÐУ¬ ......
1 javascript ÕýÔò
¶ÔÏó´´½¨ ºÍÓ÷¨
ÉùÃ÷javascript ÕýÔò
±í´ïʽ
¸´ÖÆ´úÂë
´úÂëÈçÏÂ:
var reCat = new RegExp("cat");
ÄãÒ²¿ÉÒÔ
var reCat = /cat/; //Perl ·ç¸ñ £¨ÍƼö£©
2 ѧϰ×î³£ÓÃµÄ test exec match search replace split 6¸ö·½·¨
1£© test ¼ì²éÖ¸¶¨µÄ×Ö·û´®ÊÇ·ñ´æÔÚ
¸´ÖÆ´úÂë
......
1 javascript ÕýÔò
¶ÔÏó´´½¨ ºÍÓ÷¨
ÉùÃ÷javascript ÕýÔò
±í´ïʽ
¸´ÖÆ´úÂë
´úÂëÈçÏÂ:
var reCat = new RegExp("cat");
ÄãÒ²¿ÉÒÔ
var reCat = /cat/; //Perl ·ç¸ñ £¨ÍƼö£©
2 ѧϰ×î³£ÓÃµÄ test exec match search replace split 6¸ö·½·¨
1£© test ¼ì²éÖ¸¶¨µÄ×Ö·û´®ÊÇ·ñ´æÔÚ
¸´ÖÆ´úÂë
......