js获取url中的参数值

来源:互联网 发布:保险师软件下载 编辑:程序博客网 时间:2024/05/29 18:18

     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>