¼¼ÊõµÄjsµÄreplaceĬÈÏÖ»Ìæ»»µÚÒ»¸ö£¬Õâ²»ÖªµÀÄĸöÉè¼ÆµÄ£¬Èç¹ûÎÒÊÇ A / B / C / D µÄ×Ö·û´®Òª±ä³É A-B-C-D ¾ÍÒªÔÚ±»×ªÄÚÈÝʹÓúó¼Ó/g£¬ÒòΪÓÖ´øÁË/£¬¼ÓÉϸ÷¿Õ¸ñ£¬ÔÚreplace µÄµÚÒ»¸ö²ÎÊýÓ¦¸ÃÊÇ
var rut = /\/ /g;
È»ºó
replace(rut, "-"); ......
µÚÒ»ÖÖ:
<!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>ÎÞ±êÌâÎĵµ</title>
<style type="text/css">
a
{
display:block;
height:22px;
width:90px;
font-size:15px;
padding-top:5px;
text-decoration:none;
background-color:#CCCCCC;
border-bottom:2px red solid;
}
a:hover
{
background-color:#0000FF;
color:#FFFFFF;
}
.menu .submenu
{
float:left;
margin:0px;
}
.menu .submenu ul
{
list-style-type:none;
margin:0px;
}
.menu .submenu ul li
{
display:none;
}
</style>
<script language="javascript">
function mydeel(obj,isshow)
{
var objs = obj.getElementsByTagName("li");
for(var i=0;i<objs.length;i++)
......
//Textarea maxlength
//flag:text¿òÃû×Ö£¬num:ÏÞÖÆµÄ×Ö½ÚÊý
function maxLen(flag,num){
if(document.getElementById('lastMessage').value=="0" || document.getElementById('lastMessage').value==flag){
var i=document.getElementById(flag).value.replace(/[\u0800-\uffff]/g,"\u0061\u0061\u0061").length; //byte length
if(i>num){
switch(flag){
case ("textareaName"): document.getElementById('lastMessage').value="textareaName"; break;
default: &n ......
function getCookies(name)
{
var arr = document.cookie.match(new RegExp("(^| )"+name+"=([^;]*)(;|$)"));
if(arr != null) return unescape(arr[2]); return '';
}
function setCookie(name, value, expires,
function getCookies(name)
{
var arr = document.cookie.match(new RegExp("(^| )"+name+"=([^;]*)(;|$)"));
if(arr != null) return unescape(arr[2]); return '';
}
function setCookie(name, value, expires, path, domain, secure)
{
var liveDate = new Date();
expires = liveDate.setTime(liveDate.getTime() + expires*60*1000);//ºÁÃë
//expires = new Date((new Date()).getTime() + expires * 60000);//°´·ÖÖÓ
document.cookie = name + "=" + escape (value) +
((expires) ? "; expires=" + expires : "") +
((path) ? "; path=" + path : "") +
((domain) ? "; domain=" + domain : "") +
((secure) ? "; secure" : "");
}
ÒÔÏÂÍøÉÏÕÒµÄ×ÊÁÏ:
—————————————&m ......
<script>
//дcookiesº¯Êý ×÷ÕߣºµÔÕñ¿
function SetCookie(name,value)//Á½¸ö²ÎÊý£¬Ò»¸öÊÇcookieµÄÃû×Ó£¬Ò»¸öÊÇÖµ
{
var Days = 30; //´Ë cookie ½«±»±£´æ 30 Ìì
var exp = new Date(); //new Date("December 31, 9998");
exp.setTime(exp.getTime() + Days*24*60*60*1000);
document.cookie = name + "="+ escape (value) + ";expires=" + exp.toGMTString();
}
function getCookie(name)//È¡cookiesº¯Êý
{
var arr = document.cookie.match(new RegExp("(^| )"+name+"=([^;]*)(;|$)"));
if(arr != null) return unescape(arr[2]); return null;
}
function delCookie(name)//ɾ³ýcookie
{
var exp = new Date();
exp.setTime(exp.getTime() - 1);
var cval=getCookie(name);
if(cval!=null) document.cookie= name + "="+cval+";expires="+exp.toGMTString();
} ......
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£¬ËüÊǽ«ÖÐÎÄ¡ ......