js获取地址栏参数

来源:互联网 发布:java宠物系统登入界面 编辑:程序博客网 时间:2024/05/21 12:50

页面在跳转的时候可以给他添加参数,使用?分割

<a href="location.html?id=form_home">页面跳转</a>


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;
}


获取那个form_home的参数:GetQueryString("id")

0 0