js获取url中的参数方法

直接调用函数即可,函数如下:

function getURLParam(name) {
	return decodeURIComponent((new RegExp('[?|&]' + name + '=' + '([^&;]+?)(&|#|;|$)', "ig")
	.exec(location.search) || [, ""])[1].replace(/\+/g, '%20')) || null;
}

调用如:

var id = getURLParam("id");
posted @ 2016-02-17 16:19  快乐菠菜  阅读(232)  评论(0编辑  收藏  举报