無論是前端開發還是後台設計
<script type="text/javascript">
thisURL = document
thisHREF = document
thisSLoc = self
thisDLoc = document
strwrite = " thisURL: [" + thisURL + "]<br>"
strwrite += " thisHREF: [" + thisHREF + "]<br>"
strwrite += " thisSLoc: [" + thisSLoc + "]<br>"
strwrite += " thisDLoc: [" + thisDLoc + "]<br>"
document
</script>
但有時候我們需要改變目前網址的參數/參數值
//=============== 改變網址的參數值 ================
function ChangeURLParm(Turl
//Turl: 網址
//Parm
//PValue
//ClearParm: 要清除的參數
var URL
var NewURL = Turl;//window
IsExist = false;
with(Turl){
if(indexOf(
URL = substr(
Parms = substr(indexOf(
}
else{
URL = Turl;
Parms =
}
}
if (Parms!=
var i;
ParmsArr = Parms
for(i=
if (String(Parm)
ParmsArr[i] = Parm + "=" + PValue;
IsExist = true;
if (String(ClearParm) ==""){
break;
}
}
else if ( (String(ClearParm)!="") && (String(ClearParm)
ParmsArr[i] = ClearParm + "=";
}
}
for(i=
if(i==
Parms = ParmsArr[i];
}
else{
Parms = Parms + "&" + ParmsArr[i];
}
}
NewURL = URL + "?" + Parms;
if (!IsExist){
NewURL = NewURL + "&" + Parm + "=" + PValue;
}
}
else{
NewURL = URL + "?" + Parm + "=" + PValue;
}
return NewURL;
}
其實這功能在實際應用中很好使
From:http://tw.wingwit.com/Article/program/Java/JSP/201311/20336.html