¡¶Îò͸javascript¡·Ñ§Ï°±Ê¼Ç£ºËÄ¡¢º¯ÊýµÄħÁ¦
ÒýÑÔ
JavaScriptµÄ´úÂë¾ÍÖ»ÓÐ function Ò»ÖÖÐÎʽ£¬function ¾ÍÊǺ¯ÊýµÄÀàÐÍ¡£Ò²ÐíÆäËû±à³ÌÓïÑÔ»¹ÓÐ procedure »ò method µÈ´úÂë¸ÅÄµ«ÔÚ JavaScript ÀïÖ»ÓÐ function Ò»ÖÖÐÎʽ¡£µ±ÎÒÃÇдÏÂÒ»¸öº¯ÊýµÄʱºò£¬Ö»²»¹ýÊǽ¨Á¢ÁËÒ»¸öfunctionÀàÐ͵ÄʵÌå¶øÒÑ¡£
º¯ÊýÀàÐÍ
1. ¶¨ÒåÐͺ¯Êý£¬ÈçÏ£º
<script language="javascript">
function func(){
alert("hello");
}
func();
</script>
2. ²ÎÊýÐͺ¯Êý£¬ÈçÏ£º
<script language="javascript">
func = function(){
alert("hello");
}
func();
</script>
Ô¤±àÒë
ÏëÏëÏÂÏÂÃæµÄ´úÂ룬ȻºóÖ´Ðп´½á¹û
<script language="javascript">
function func(){
alert("hello");
}
func();
function func(){
alert("hi~~");
}
func();
</script>
ÉÏÃæµÄ´úÂ룬½á¹ûÁ½´Î¶¼µ¯³ö“hi~~”£¬ÕâÊÇΪʲô£¿ÔÀ´£¬JavaScript Ö´ÐÐÒýÇæ²¢·ÇÒ»ÐÐÒ»ÐеطÖÎöºÍÖ´ÐгÌÐò£¬¶øÊÇÒ»¶ÎÒ»¶ÎµØ·ÖÎöÖ´Ðеġ£¶øÇÒ£¬ÔÚͬһ¶Î³ÌÐòµÄ·ÖÎöÖ´ÐÐÖУ¬¶¨ÒåʽµÄº¯ÊýÓï¾ä»á±»ÌáÈ¡³öÀ´ÓÅÏÈÖ´ÐС£º¯Êý¶¨ÒåÖ´ÐÐÍêÖ®ºó£¬²Å»á°´Ë³ÐòÖ´ÐÐÆäËûÓï¾ä´úÂë¡£Ò²¾ÍÊÇ˵£¬ÔÚµÚÒ»´Îµ÷ÓÃfunc֮ǰ£¬µÚÒ»¸öº¯ÊýÓï¾ä¶¨ÒåµÄ´úÂëÂß¼£¬Òѱ»µÚ¶þ
¸öº¯Êý¶¨ÒåÓï¾ä¸²¸ÇÁË¡£ËùÒÔ£¬Á½´Î¶¼µ÷Óö¼ÊÇÖ´ÐÐ×îºóÒ»¸öº¯ÊýÂß¼ÁË¡££¨Õâʵ¼ÊÉϾÍÊÇÒòΪֻÓÐÒ»¸öº¯Êý±äÁ¿£¬È´¶à´Î¸³Öµ£¬ËùÒÔµ±È»Ö»»á±£Áô×îºóÒ»´ÎµÄ¸³ÖµÁË£©
ÉÏÃæµÄÇé¿ö³öÏÖµÄÇ°ÌáÊÇjs±ØÐëÔÚͬһ´úÂë¿ìÖУ¬Èç¹ûÁ½¸öͬÑùµÄº¯ÊýÔÚ²»Í¬µÄ´úÂë¿éÖоͲ»»á³öÏÖÉÏÃæµÄ×´¿öÁË£¬ÈçÏ£º
<script language="javascript">
function func(){
alert("hello");
}
func();
</script>
<script language="javascript">
function func(){
alert("hi~~");
}
func();
</script>
ÊÔÒ»ÊÔ
1. ÏÈÓÃÄÔ´üÔËÐгö½á¹û£¬È»ºóÔÙÖ´ÐбȽÏ
<script language="javascript">
func = funct
Ïà¹ØÎĵµ£º
JavaScript replace() ·½·¨
JavaScript String ¶ÔÏó²Î¿¼ÊÖ²á
¶¨ÒåºÍÓ÷¨
replace() ·½·¨ÓÃÓÚÔÚ×Ö·û´®ÖÐÓÃһЩ×Ö·ûÌæ»»ÁíһЩ×Ö·û£¬»òÌæ»»Ò»¸öÓëÕýÔò±í´ïʽƥÅäµÄ×Ó´®¡£
Óï·¨
stringObject.replace(regexp,replacement)
²ÎÊýÃèÊö
regexp
±ØÐè¡£¹æ¶¨ÁËÒªÌæ»»µÄģʽµÄ RegExp ¶ÔÏó¡£Çë×¢Ò⣬Èç¹û¸ÃÖµÊÇÒ»¸ö×Ö·û´®£¬Ôò½ ......
JavaScriptʼþ·ÖÀࣺ
1¡¢²¶»ñÐÍ£¨IE²»Ö§³Ö£©£¨´ÓDOM½á¹¹µÄ×¶Ë¿ªÊ¼ÏòÏÂÑÓÉ죩
2¡¢Ã°ÅÝÐÍ£¨´ÓDOM½á¹¹µÄ×îµÍ¶ËÏòÉÏÒ»¼¶¼¶ÑÓÉ죩
¡¾IE7ÒÔÉÏ¿ÉÒÔ¸ø‘html’Ìí¼Óonclickʼþ£¬IEÖÐbody->html£¬»ðºüÖÐhtml->body¡¿
JavaScriptÌí¼Óʼþ¼àÌý£º
1¡¢IE£º
[object].attachEvent("event_handler", fnHandler); ......
¡¶Îò͸JavaScript¡·Ñ§Ï°±Ê¼Ç
ÔÎĵØÖ·£ºhttp://www.cnblogs.com/leadzen/archive/2008/02/25/1073404.html
ÕâÊÇÒ»±¾ºÜÐÎÏóÉú¶¯µÄÊ飬ʹÎÒÃÇ¿ÉÒÔ¸üÉîµØÁ˽âÁËJavaScript¡£
ÒýÑÔ
±à³ÌÊÀ½çÀïÖ»´æÔÚÁ½ÖÖ»ù±¾ÔªËØ£¬Ò»¸öÊÇÊý¾Ý£¬Ò»¸öÊÇ´úÂë¡£±à³ÌÊÀ½ç¾ÍÊÇÔÚÊý¾ÝºÍ´úÂëǧ˿ÍòÂƵ ......
ÒýÑÔ
JavaScriptûÓÐ “Àà”µÄ¸ÅÄÕâÈúܶàѧϰ¹ý¸ß¼¶ÓïÑÔµÄÈ˸е½ºÜ²»Ë¬£¬Æäʵ±ÈÖ®ÓÚCÓïÑÔÓÖÈçºÎÄØ£¿ÏÔÈ»JavaScriptÒª±ÈCÓïÑÔºÃÓúܶࡣ
²»·Ï»°£¬ÉÏ´úÂë
<script language="javascript">
/*Ò»¾ä¾äµÄ¿´¸üÈÝÒ×Ã÷°×*/
//ÉùÃ÷Ò»¸ö¶ÔÏ󣬵«Ëüʲô¶¼Ã»ÓÐ
var life = {};
//ÈÎ ......