修改地址后的参数:
<script>
function getNewUrl(oldurl,paramname,pvalue){
var reg = new RegExp("(\\?|&)"+ paramname +"=([^&]*)(&|$)","gi");
var t=oldurl.match(reg)[0];
var retxt=t.substring(0,t.indexOf("=")+1)+pvalue;
if(t.charAt(t.length-1)=='&') retxt+="&";
return oldurl.replace(reg,retxt);
}
alert(getNewUrl("http://servername/virturlpath/index.asp?p1=123&p2=aa&p3=hh&p4=1","p4","cxz"));
</script>
获取地址参数:
<script>
function aa(source, name)
{
var reg = new RegExp("(^|\\?|&)"+ name +"=([^&]*)(\\s|&|$)", "i");
if (reg.test(source)) return RegExp.$2; return "";
};
alert(aa("http://community.csdn.net/Expert/topic/4223/4223277.xml?temp=6.502932E-02", "temp"))
</script>
Word教程网 | Excel教程网 | Dreamweaver教程网 | Fireworks教程网 | PPT教程网 | FLASH教程网 | PS教程网 |
HTML教程网 | DIV CSS教程网 | FLASH AS教程网 | ACCESS教程网 | SQL SERVER教程网 | C语言教程网 | JAVASCRIPT教程网 |
ASP教程网 | ASP.NET教程网 | CorelDraw教程网 |