window.location下的属性说明

window.location下的属性说明_第1张图片
image.png

var href = window.location.href;//完整的url
var protocol = window.location.protocol;//协议
var hostname = window.location.hostname;//主机名
var host = window.location.host;//主机名+端口号
var port = window.location.port;//端口号
var pathname = window.location.pathname;//当前URL的路径部分
var search = window.location.search;//路径的查询部分
var hash = window.location.hash;//开始的锚点
var url = location.search; //获取url中"?"符后的字串

function GetRequest() {
var url = location.search; //获取url中"?"符后的字串
var theRequest = new Object();
if (url.indexOf("?") != -1) {
var str = url.substr(1);
strs = str.split("&");
for(var i = 0; i < strs.length; i ++) {
theRequest[strs[i].split("=")[0]]=unescape(strs[i].split("=")[1]);
}
}
return theRequest;
}
结果

window.location下的属性说明_第2张图片
image.png

(https://blog.csdn.net/flygoa/article/details/49998373)侵删

你可能感兴趣的:(window.location下的属性说明)