shuiche

以路径为 http://www.baidu.com  为例

console.log("location:"+window.location.href);
>> "https://www.baidu.com/"

console.log("location:"+window.location.hostname);
>> "www.baidu.com/"

console.log("location:"+window.location.protocol);
>> "https:"

console.log("location:"+window.location.host);
>> "www.baidu.com"

console.log("location:"+window.location.port);
>> ""  
#说明一下, 这里是指默认端口, http默认为80端口, https默认为443端口.如果有端口号, 这里会返回端口号的字符串

 

看一下   window.location 具体有哪些内容:

 

分类:

技术点:

相关文章:

  • 2021-12-03
  • 2021-12-13
  • 2021-12-17
  • 2021-10-16
  • 2021-12-14
  • 2021-12-23
  • 2021-12-14
  • 2021-06-15
猜你喜欢
  • 2021-10-16
  • 2021-10-16
  • 2021-09-05
  • 2021-12-13
  • 2021-10-18
  • 2021-10-16
  • 2021-11-27
相关资源
相似解决方案