js获取url中的参数方法

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

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

调用如:

var id = getURLParam("id");
原文地址:https://www.cnblogs.com/klbc/p/5195718.html