js获取Url相关信息和参数值
var thisUrlHost = document.location.host, //获取当前Url域名(含端口)thisUrlDomain = document.domain, //获取当前Url域名(不含端口)
thisUrl = window.location.href; //获取当前完整Url地址
//获取Url参数值
function getUrlParamVal(paramName) {
var reg = new RegExp('(^|&)' + paramName + '=([^&]*)(&|$)', 'i');
var r = window.location.search.substr(1).match(reg);
if (r != null) {
return unescape(r[2]);
}
return '';
}
分享到: