//想url中加入参数,暂时正则表达是带参数替换尚有问题 function addUrlPara(name, value) { var currentUrl = window.location.href.split('#')[0]; if (/\?/g.test(currentUrl)) { if (/name=[-\w]{4,25}/g.test(currentUrl)) { currentUrl = currentUrl.replace(/name=[-\w]{4,25}/g, name + "=" + value); } else { currentUrl += "&" + name + "=" + value; } } else { currentUrl += "?" + name + "=" + value; } if (window.location.href.split('#')[1]) { window.location.href = currentUrl + '#' + window.location.href.split('#')[1]; } else { window.location.href = currentUrl; } }