url: http://xxxx.com?name=魅力&id=123 js中: var name = getUrlParam("name"); /*通過正則獲取url中的參數*/function getUrlParam(name){ var reg = new RegExp("(^|&)"+ na ...
url:
http://xxxx.com?name=魅力&id=123
js中:
var name = getUrlParam("name");
/*通過正則獲取url中的參數*/
function getUrlParam(name){
var reg = new RegExp("(^|&)"+ name +"=([^&]*)(&|$)");
var r = window.location.search.substr(1).match(reg);
if(r!=null)return decodeURI(r[2]); return null;
}