日期:2014-05-17 浏览次数:21006 次
<script type='text/javascript'> RegExp.escape = function(str) { return (str||'').replace(/([.*+?^=!:${}()|[\]\/\\])/g, '\\$1'); }; function changeParam(name, value) { name = encodeURIComponent(name); var p = name + "=" + encodeURIComponent(value); var href = location.href; if (!/\?/.test(href)) return location.href = href.replace(/[^?&=#]+/, '$&?' + p); if (new RegExp("\\b" + RegExp.escape(name) + "=", "ig").test(href.split("?")[1])) return location.href = href.replace(new RegExp("\\b" + RegExp.escape(name) + "\\=[^&#]*", "ig"), p); return location.href = href.replace(/[^?&=#]+\?/, '$&' + p + "&"); } </script> <select name="select1" onchange="changeParam('n', this.value)"> <option selected>请选择</option> <option value="1">第一项</option> <option value="2">第二项</option> </select>
------解决方案--------------------
測試過樓主的代碼沒有問題喔