Code
<script>
//var searchname,searchv;
function orderby(searchname,searchv){
var href=window.location.href;//网址全部地址
var vyes=window.location.search;//有没有带参数
if(vyes!=''){
var r,rtop,rend;
r=vyes.search(searchname);//出现的位置
if(r!=-1){//如果查询中有这个查询名
rtop=vyes.substr(0,r);
rend=vyes.substr(r);
var r2=rend.search('&');
//var r2=searchname.length+searchv.length+1;
if(r2!=-1){
rend=rend.substr(r2);
//alert(rtop+searchname+'='+searchv+rend);
location=window.location.pathname+rtop+searchname+'='+searchv+rend;
}else{//如果后面没有&了.
location=window.location.pathname+rtop+searchname+'='+searchv;
}
}else{//如果没有这个查询名
location=href+'&'+searchname+'='+searchv;
}
//var oldsearchv;
//href=href.replace(searchname+'='+oldsearchv,"")//清除空参数
}else{
location=href+'?'+searchname+'='+searchv;
}
}
</script>
js根据地址栏参数跳转页面.
<a href="javascript:orderby('a','b');">aa</a>
<a href="javascript:orderby('a','');">aa</a>
<a href="javascript:orderby('a','c');">aa</a>