JavaScriptÖÐµÄ escape,encodeURI,encodeURIComponent
js¶ÔÎÄ×Ö½øÐбàÂëÉæ¼°3¸öº¯Êý£ºescape,encodeURI,encodeURIComponent£¬ÏàÓ¦3¸ö½âÂ뺯Êý£ºunescape,decodeURI,decodeURIComponent
1¡¢ ´«µÝ²ÎÊýʱÐèҪʹÓÃencodeURIComponent£¬ÕâÑù×éºÏµÄurl²Å²»»á±»#µÈÌØÊâ×Ö·û½Ø¶Ï¡£
ÀýÈ磺<script language="javascript">document.write('<a href="http://passport.baidu.com/?logout&aid=7&u='+encodeURIComponent("http://cang.baidu.com/bruce42")+'">Í˳ö</a>');</script>
2¡¢ ½øÐÐurlÌø×ªÊ±¿ÉÒÔÕûÌåʹÓÃencodeURI
ÀýÈ磺Location.href=encodeURI("http://cang.baidu.com/do/s?word=°Ù¶È&ct=21");
3¡¢ jsʹÓÃÊý¾Ýʱ¿ÉÒÔʹÓÃescape
[Huoho.Com±à¼]
ÀýÈ磺ËѲØÖÐhistory¼Í¼¡£
4¡¢ escape¶Ô0-255ÒÔÍâµÄunicodeÖµ½øÐбàÂëʱÊä³ö%u****¸ñʽ£¬ÆäËüÇé¿öÏÂescape£¬encodeURI£¬encodeURIComponent±àÂë½á¹ûÏàͬ¡£
×î¶àʹÓõÄӦΪencodeURIComponent£¬ËüÊǽ«ÖÐÎÄ¡¢º«ÎĵÈÌØÊâ×Ö·ûת»»³Éutf-8¸ñʽµÄurl±àÂ룬ËùÒÔÈç¹û¸øºǫ́´«µÝ²ÎÊýÐèҪʹÓÃencodeURIComponentʱÐèÒªºǫ́½âÂë¶Ôutf-8Ö§³Ö£¨formÖеıàÂ뷽ʽºÍµ±Ç°Ò³Ãæ±àÂ뷽ʽÏàͬ£©
escape²»±àÂë×Ö·ûÓÐ69¸ö£º*£¬+£¬-£¬.£¬/£¬@£¬_£¬0-9£¬a-z£¬A-Z
encodeURI²»±àÂë×Ö·ûÓÐ82¸ö£º!£¬#£¬$£¬&£¬'£¬(£¬)£¬*£¬+£¬,£¬-£¬.£¬/£¬:£¬;£¬=£¬?£¬@£¬_£¬~£¬0-9£¬a-z£¬A-Z
encodeURIComponent²»±àÂë×Ö·ûÓÐ71¸ö£º!£¬ '£¬(£¬)£¬*£¬-£¬.£¬_£¬~£¬0-9£¬a-z£¬A-Z
Ïà¹ØÎĵµ£º
Ò³ÃæÆÁ±ÎÁ˻سµ£¬½á¹û¶àÐÐÊäÈëµÄTextbox±¯¾çÁË£¬Ö»ÄÜÓÃjsÖØÐ´»Ø³µÊ¼þ£¬±¸·ÝÒ»ÏÂ
pageloadÀï
txt_eng.Attributes.Add("onkeypress", "enter(this)");
js£º
function enter(obj) {
if (event.keyCode == 13) {
&nb ......
<input type="text" onblur="if (value ==''){value='ÇëÊäÈë¹Ø¼ü×Ö'}" onfocus="if (value =='ÇëÊäÈë¹Ø¼ü×Ö'){value =''}" id="q" name="q" value="ÇëÊäÈë¹Ø¼ü×Ö" style="width: 100px; height: 14px;">
......
µÚÒ»ÖÖ:
<!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=utf-8" />
<title>ÎÞ±êÌâÎ ......
<script>
//дcookiesº¯Êý ×÷ÕߣºµÔÕñ¿
function SetCookie(name,value)//Á½¸ö²ÎÊý£¬Ò»¸öÊÇcookieµÄÃû×Ó£¬Ò»¸öÊÇÖµ
{
var Days = 30; //´Ë cookie ½«±»±£´æ 30 Ìì
var exp = new Date(); //new Date("December 31, 9998");
......