GET請求會將中文編碼,如果取出亂碼的話,應該進行解碼操作,
下面的函數是獲取指定參數名的參數值,參數值可是中文、英文。
function getQueryString(name) {
var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)", "i"); var r = window.location.search.substr(1).match(reg); if (r != null) return decodeURIComponent(r[2]); return null; }
注意: 需要在頁面head中添加下面這個meta標簽
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />