您的位置:首页 > Web前端

前端JS解析url参数及客户端环境

2012-04-08 20:17 417 查看
//获得 GET参数

function $_GET( ) {

var re = new RegExp("([^\&\?]*)=([^\&]*)", "i");

var a = re.exec(document.location.search);

window.GET = [];

while (a){

GET[a[1]] = a[2];

a = re.exec(document.location.search);

}

return GET;

};

其它参数

//获得域名地址 location.origin

//获得文件路径 location.pathname

//获得hash字符串 location.hash

//获得历史页面步骤 history.length

//获得cookie document.cookie
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: