js获取url中的参数值

     jsp中页面的跳转常常需要带一些参数,不是前后台分离,要自己做了。所以找到了如何获取URL中参数值的方法,这是目前为止小编在本项目中用到最多的方法。

<script type="text/javascript">
						function GetQueryString(name)
							{
							     var reg = new RegExp("(^|&)"+ name +"=([^&]*)(&|$)");
							     var r = window.location.search.substr(1).match(reg);
							     if(r!=null)return  unescape(r[2]); return null;
							}
							function addGoods(){
								alert(GetQueryString("seckillId"));
								window.location.href = BASE_URL +"/back/busiGoodsParam/add?styleId="+GetQueryString("styleId");
							}	
</script>


猜你喜欢

转载自blog.csdn.net/zhang18330699274/article/details/78834572