JS 获取URL参数

function getUrlParm(name) {
    var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)", "i"),
	  r = window.location.search.substr(1).match(reg);
    if (r != null) return unescape(r[2]); return null;
}

eg:

http://www.abc.com/index?parname=1234567

console.log(getUrlParm(parname));

output:

1234567

posted @ 2013-08-07 13:18  Younger  阅读(312)  评论(0编辑  收藏  举报