一、获取域名
let domain = document.domain;
let domain = window.location.host;
二、获取url
let url = window.location.href;
let url = self.location.href;
let url = document.URL;
let url = document.location;
三、获取相对路径
function getRelativePath()
{
let url = document.location.toString();
let arrurl = url.split("//");
let start = arrurl[1].indexOf("/");
let newurl = arrurl[1].substring(start);
if(newurl .indexOf("?") != -1){
newurl = newurl .split("?")[0];
}
return newurl ;
}
四、获取url参数
function getPara()
{
let url = document.location.toString();
let arrurl = url.split("?");
let p = arrurl[1];
return p;
}
五、获取当前域名使用的协议(更新)
let hxy = document.location.protocol; //// http:或https:
网友评论