前端JS解析url参数及客户端环境
2012-04-08 20:17 刘联东 阅读(295) 评论(0) 编辑 收藏 举报//获得 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