escape返回以 ISO-Latin-1 字符集书写的参数的十六进制编码。
语法escape("string")
参数
描述escape 函数是一个顶级 JavaScript 函数,并不与任何对象关联。使用 escape 和 unescape 函数可以将属性值手工添加到 URL 中。
escape 函数编码指定字符串中的特定字符,并返回新字符串。它编码空格、标点符号及其它不位于 ASCII 字母表的字符,除了以下字符:
* @ - _ + . /
示例示例 1. 下面的例子返回 "%26":
escape("&")
示例 2. 该语句
escape("The_rain. In Spain, Ma'am") 返回
"The_rain.%20In%20Spain%2C%20Ma%92am":
示例 3. 在下面的例子中,如果用户单击链接的话,变量 theValue 的值将被以十六进制字符串编码并被传送给 request 对象:
<A HREF=\Q"mypage.html?val1="+escape(theValue)\Q)>Click Here</A>
参看
unescape
script 如何转换特殊 字符
<script type="text/javascript"> var swf_width=230 var swf_height=166 var files='uploadfile/<%=aboutpic%>|uploadfile/<%=aboutpicc%>|uploadfile/<%=aboutpiccc%>|uploadfile/<%=aboutpicccc%>|uploadfile/<%=aboutpiccccc%>' //这里是切换图片的相对地址,以"|"分割图片.数目无限制. var links='<%=abouturl%>|<%=abouturll%>|<%=abouturlll%>|<%=abouturllll%>|<%=abouturlllll%>' //这里是图片对应的链接.可以是绝对也可以是相对. document.write('<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0" width="'+ swf_width +'" height="'+ swf_height +'">'); document.write('<param name="movie" value="images/flash.swf"><param name="quality" value="high">'); document.write('<param name="menu" value="false"><param name=wmode value="opaque">'); document.write('<param name="FlashVars" value="bcastr_file='+files+'&bcastr_link='+escape(links)+'">'); document.write('<embed src="images/flash.swf" wmode="opaque" FlashVars="bcastr_file='+files+'&bcastr_link='+escape(links)+'& menu="false" quality="high" width="'+ swf_width +'" height="'+ swf_height +'" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />'); document.write('</object>'); </script> |