function set_param(param,value){ var query = location.search.substring(1); var p = new RegExp("(^|&"+param+")=[^&]*"); if(p.test(query)){ query = query.replace(p,"$1="+value); location.search = '?'+query; }else{ if(query == ''){ location.search = '?'+param+'='+value; }else{ location.search = '?'+query+'&'+param+'='+value; } } }