Ò׽ؽØͼÈí¼þ¡¢µ¥Îļþ¡¢Ãâ°²×°¡¢´¿ÂÌÉ«¡¢½ö160KB
ÈÈÃűêÇ©£º c c# c++ asp asp.net linux php jsp java vb Python Ruby mysql sql access Sqlite sqlserver delphi javascript Oracle ajax wap mssql html css flash flex dreamweaver xml
 ×îÐÂÎÄÕ : javascript

javascript trim·½·¨

ÔÚjavascriptÖеÄstring¶ÔÏóûÓÐtrim·½·¨£¬ËùÒÔtrim¹¦ÄÜÐèÒª×Ô¼ºÊµÏÖ£º
´úÂëÈçÏ£º
Java´úÂë
﹤scriptlanguage=”javascript”﹥   
/**  
*ɾ³ý×óÓÒÁ½¶ËµÄ¿Õ¸ñ  
*/  
String.prototype.trim=function(){      
    return this.replace(/(^\s*)|(\s*$)/g, '');   
}     
/**  
*ɾ³ý×ó±ßµÄ¿Õ¸ñ  
*/  
String.prototype.ltrim=function()   
{   
  return this.replace(/(^s*)/g,'');   
}   
/**  
*ɾ³ýÓұߵĿոñ  
*/  
String.prototype.rtrim=function()   
{   
  return this.replace(/(s*$)/g,'');   
}   
﹤/script﹥  
﹤scriptlanguage=”javascript”﹥
/**
*ɾ³ý×óÓÒÁ½¶ËµÄ¿Õ¸ñ
*/
String.prototype.trim=function(){
return this.replace(/(^\s*)|(\s*$)/g, ......

JavaScript µ÷ÓÃ±íµ¥ÖØÖ÷½·¨


1 history.go(0)  
2 location.reload() £¨Ò³Ãæ½øÐÐˢУ¬µ«ÎªdisabledµÄÔªËصÄÖµ²»»á±»Çå¿Õ£©
3 location=location 
4 location.assign(location) 
5 location.replace(location) 
6 from..reset()  (Ò³Ãæ²»½øÐÐˢУ¬Ä£Äâµ¥»÷¶ÔËùµ÷ÓÃ±íµ¥ÖØÖð´Å¥µÄµ¥»÷)
......

JavaScriptÖÐconfirm,alert,promptµÄÓ÷¨

±¾ÎļòÒª½éÉÜJavaScriptÖÐconfirm,alert,promptµÄÓ÷¨,Ï£Íû´ó¼Òѧϰ¹ý³ÌÖÐÄܵõ½Ò»Ð©Æô·¢¡£
window.confirm ²ÎÊý¾ÍÖ»ÓÐÒ»¸ö¡£ÏÔʾÌáʾ¿òµÄÐÅÏ¢¡£°´È·¶¨,·µ»Øtrue£»°´È¡Ïû·µ»Øfalse¡£
< SCRIPT> var bln = window.confirm("È·¶¨Âð?"); alert(bln) < /SCRIPT> window.alert²ÎÊý£¬Ö»ÓÐÒ»¸ö£¬ÏÔʾ¾¯¸æ¿òµÄÐÅÏ¢£»ÎÞ·µ»ØÖµ¡£
< SCRIPT> window.alert("È·¶¨¡£") window.prompt²ÎÊý,ÓÐÁ½¸ö£¬µÚÒ»¸ö²ÎÊý£¬ÏÔʾÌáʾÊäÈë¿òµÄÐÅÏ¢¡£µÚ¶þ¸ö²ÎÊý,ÓÃÓÚÏÔʾÊäÈë¿òµÄĬÈÏÖµ¡£·µ»Ø£¬Óû§ÊäÈëµÄÖµ¡£
< SCRIPT> var str = window.prompt("ÇëÊäÈëÃÜÂë","password") alert(str); < /SCRIPT>
......

JavaScriptÖÐÄäÃûº¯Êý£¬º¯ÊýÖ±½ÓÁ¿ºÍ±Õ°ü(ת)

Ô­Îijö´¦: http://www.dnew.cn/post/196.htm
ÏÈ¿´ÏÂÏÂÃ漸ÖÖд·¨
1.function f(x){return x*x;};f(x);
2.(function(x){return x*x;})(x);
3.(function(x){return x*x;}(x));
µÚÒ»ÖÖÎÒÃÇÓ¦¸Ã¶¼ºÜÊìϤÁË£¬ÕâÊÇÎÒÃǾ­³£Ê¹ÓõÄд·¨¡£µÚ¶þµÚÈýÖÖ¶¼ÊÇÄäÃûº¯ÊýµÄд·¨¡£
--------------------------------------------------------------------------------
µÚ¶þÖÖ
¿ÉÒÔÕâÑùÀí½â£º
•var f=function(x) {return x*x;};f()
ÄÇÎÒÃDz»Í¨¹ýfÕâ¸ö±äÁ¿À´ÒýÓú¯Êý¾ÍÊÇ
•function(){}()
È»¶øÕâÑù¿Ï¶¨ÊÇ´íÎóµÄ¾ÍÏñ
•var f=1+2;
•f=f*0;
Óë
•var f=1+2*0;
½á¹û²»Í¬Ò»Ñù¡£
ÒªµÃµ½ÕýÈ·½á¹ûÖ»ÄÜ£º
•f=(1+2)*0;
Ò²¾ÍÊÇÒªÃ÷È·µÄ±êʶ³ö³ÌÐò¿é,¼´£º
•(function(){})()
¿ÏÄãÓÐÒÉÎÊ£ºÀ¨ºÅ“()”µ½µ×ÊDz»ÊÇÆðµ½Á˱êʶ´úÂë¿éµÄ×÷Óã¿
ÎÒÃÇ¿ÉÒÔÓÃJavaScriptµÄÄÚÖú¯Êý¼ì²âһϣ¡
¾ÙÒ»¸ö×î¼òµ¥µÄÀý×Ó£º
•alert(4)
Õâ¶Î´úÂë»áµ¯³öÌáʾÄÚÈÝÊÇ“4”
¸Ä³ÉÕâÑù
•(alert)(4)
¿ÉÒÔ¿´µ½Ö´ÐеÄЧ¹ûºÍÉÏÒ»¶Î´úÂëÒ»Ñù¡£
ÕâÖÖÐÎʽµÄº¯ÊýÖ´ÐÐÒ²±»ºÜ¶àJavaScript¿ò¼ÜËù²ÉÓá£
------------------------ ......

href=¡°#¡±Óëhref=¡°javascript:void(0)¡±Çø±ð

ʹÓùýajaxµÄ¶¼³£¼ûÕâÑùµÄ´úÂ룺
<a href="javascript:doTest2();void(0);" mce_href="javascript:doTest2();void(0);">here</a>
µ«Õâ¶ùµÄvoid(0)¾¿¾¹ÊǺκ¬ÒåÄØ£¿
JavascriptÖÐvoidÊÇÒ»¸ö²Ù×÷·û£¬¸Ã²Ù×÷·ûÖ¸¶¨Òª¼ÆËãÒ»¸ö±í´ïʽµ«ÊDz»·µ»ØÖµ¡£
void ²Ù×÷·ûÓ÷¨¸ñʽÈçÏ£º
1. javascript:void (expression)
2. javascript:void expression
expression ÊÇÒ»¸öÒª¼ÆËãµÄ Javascript ±ê×¼µÄ±í´ïʽ¡£±í´ïʽÍâ²àµÄÔ²À¨ºÅÊÇÑ¡µÄ£¬µ«ÊÇдÉÏÈ¥ÊÇÒ»¸öºÃÏ°¹ß¡£ (ʵÏÖ°æ±¾ Navigator 3.0 )
ÄãÒÔʹÓà void ²Ù×÷·ûÖ¸¶¨³¬¼¶Á´½Ó¡£±í´ïʽ»á±»¼ÆË㵫ÊDz»»áµ±Ç°Îĵµ´¦×°ÈëÈκÎÄÚÈÝ¡£
ÏÂÃæµÄ´úÂë´´½¨ÁËÒ»¸ö³¬¼¶Á´½Ó£¬µ±Óû§ÒԺ󲻻ᷢÉúÈκÎÊ¡£µ±Óû§Á´½Óʱ£¬void(0) ¼ÆËãΪ 0£¬µ« Javascript ÉÏûÓÐÈκÎЧ¹û¡£
<A HREF="javascript:void(0)" mce_HREF="javascript:void(0)">µ¥´Ë´¦Ê²Ã´Ò²²»»á·¢Éú</A>
ÏÂÃæµÄ´úÂë´´½¨ÁËÒ»¸ö³¬¼¶Á´½Ó£¬Óû§µ¥Ê±»áÌá½»±íµ¥¡£
<A HREF="javascript:void(document.form.submit())" mce_HREF="javascript:void(document.form.submit())">
µ ......

javaScript»ñÈ¡¶ÔÏ󼯺ϣ¨ÁíÒ»ÖÖ·½·¨£©

³ýÁËÓÃgetElementByTagName   µÄÁíÒ»ÖÖ»ñÈ¡¶ÔÏ󼯺ϵķ½·¨
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>ÎÞ±êÌâÎĵµ</title>
</head>
<body>
<form id="one" name="one">
<input type="text" title="sadf" sd="sdf" name="hello" id="hello" value="1" />
<input type="text" name="hello" sd="sasdfasdf" id="hello" value="2" />
<input type="text" name="hello" id="hello" value="3" />
<input type="text" name="hello" id="hello" value="4" />
<input type="text" name="hello" id="hello" value="5" />
<input type="text" name="hello" id="hello" value="6" />
<input type="text" name="hello" id="hello" value="7" />
<input type="text" name="hello" id="hello" value="8" /& ......
×ܼǼÊý:2244; ×ÜÒ³Êý:374; ÿҳ6 Ìõ; Ê×Ò³ ÉÏÒ»Ò³ [1] 2 [3] [4] [5] [6] [7] [8] [9] [10]  ÏÂÒ»Ò³ βҳ
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ