javascriptÕýÔò±í´ïʽʵÏÖtrim()ÒÉ»ó
ÕýÔÚ¿´¡¡javascript¸ß¼¶³ÌÐòÉè¼Æ¡¡,ÆäÖйØÓÚ·Ö×éÀïÃæµÄÒ»¾ä´úÂë²»ÊÇÌ«Àí½â:
ͨ¹ýÅäºÏʹÓÃString¶ÔÏóµÄreplace()·½·¨¼°·´ÏòÒýÓ㬾ͿÉÒÔ¶¨Òå×Ô¼ºµÄtrim()·½·¨:
String.prototype.trim = function() {
var reExtraSpace = /^\s+(.*?)\s+$/;
return this.replace(reExtraSpace,"$1");
}
Ò»¿ªÊ¼ÔõôҲ²»Àí½â trim() ·½·¨ÊÇÔõôÆð×÷ÓõÄ
var sTest = " this is a test ";
alert("[" + sTest + "]"); //outputs " [ this is a test ] "
alert("[" + sTest.trim() + "]"); outputs " [this is a test] "
ºóÀ´²éÁËһϡ¡javascript ÀïÃæ StringObject µÄ replace(regexp,replacement)
·½·¨µÄµÚ¶þ¸ö²ÎÊýreplacementÀïÃæµÄ"$"ÌØÊ⺬Ò壺
$n±íʾµÚ n ¸ö×Ó±í´ïʽ , Ò²¾ÍÊÇ .*?
ÔÀ´·Ö×é¾ÍÊÇÕýÔò±í´ïʽµÄ×Ó±í´ïʽ
Ïà¹ØÎĵµ£º
1.asp.netºô½Ðjs
view
plain
copy
to clipboard
print
?
Response.Write("<mce:script language=javascript><!--
");
Response.Write("alert('Ȧ ');"
);
Response.Write("location.href='login.aspx';"
)& ......
ECMAScriptÓÐÎÞÓô洢µ¥ÔªÊÕ¼¯³ÌÐò£¬µ±ÔÚÔÙûÓжԶÔÏóµÄÒýÓÃʱ£¬³Æ¸Ã¶ÔÏ󱻷ϳý£¨dereference£©ÁË¡£
ÔËÐÐÎÞÓô洢µ¥ÔªÊÕ¼¯³ÌÐòʱ£¬ËùÓзϳýµÄ¶ÔÏ󶼱»Ïú»Ù¡£
°Ñ¶ÔÏóµÄËùÓÐÒýÓö¼ÉèÖÃΪnull£¬¿ÉÒÔÇ¿ÖÆÐԵķϳý¶ÔÏó£¬ÀýÈ磺
var oObject = new Object;
.......
&n ......
1.Dean Edwards±àдµÄPacker£¨http://dean.edwards.name/packer/£©£¬ÓÃÓÚѹËõJavaScript
2.»ñÈ¡JQuery£ºhttp:/jquery.com
http://docs.jquery.com/Downloading_jQuery ÏÂÔظ÷¸ö°æ±¾¼°ÏàÓ¦°ïÖúÎ ......
ECMAScriptÖУ¬switchÓï¾ä¿ÉÒÔÓÃÓÚ×Ö·û´®£¬¶øÇÒÄÜÓò»Êdz£Á¿µÄֵ˵Ã÷Çé¿ö:
var BLUE="blue" , RED = "red" , GREEN = "green";
switch(sColor)
{
case BLUE: alert("Blue"); break;
&nb ......
ÒýÓÃÀàÐÍͨ³£½Ð×öÀࣨclass£©£¬Óöµ½ÒýÓÃֵʱ£¬Ëù´¦ÀíµÄ¾ÍÊǶÔÏó¡£
¶ÔÏóµÄ´´½¨£º
var o = new Object();
Èç¹ûûÓвÎÊý¿ÉÒÔÊ¡ÂÔÀ¨ºÅ£¬È磺var o = new Object;
ObjectÀࣺ
&nb ......