修改地址后的参数:
<script>
function getNewUrl(oldurl,paramname,pvalue){
var reg = new RegExp("(\?|&)"+ nome do parâmetro +"=([^&]*)(&|$)","gi");
var t=oldurl.match(reg)[0];
var retxt=t.substring(0,t.indexOf("=")+1)+pvalue;
if(t.charAt(t.length-1)=='&') retxt+="&";
retornar url antigo.replace(reg,retxt);
}
alert(getNewUrl(" http://servername/virturlpath/index.asp?p1=123&p2=aa&p3=hh&p4=1","p4","cxz "));
</script>
获取地址参数:
<script>
função aa(fonte, nome)
{
var reg = new RegExp("(^|\?|&)"+ nome +"=([^&]*)( \s|&|$ )", "i");
if (reg.test(fonte)) retornar RegExp.$2; retornar "";
};
alerta(aa(" http://community.csdn.net/Expert/topic/4223/4223277.xml?temp=6.502932E-02 ", "temp"))
</script>