js获取当前页的url信息。

1,将整个URL设置为字符串:

window.location.href

2,设置或获取与URL相关联的端口号:

window.location.port

三.设置或获取URL的协议部分

window.location.protocol

4、设置或获取部分的问号后面的href属性

window.location.search

5。获取变量的值(截取相等后的部分)
复制代码代码如下所示:
var url = window.location.search;
警报(URL长度);
/ /警报(url.lastindexof(t));
无功禄= url.substring(url.lastindexof,+ 1,url.length(t));

6。设置或获取URL的协议部分:

window.location.protocol

7、集或元素的href属性#威尔斯号进入后段:

window.location.hash

8、设置或获取主机名和端口号的位置或URL:

window.location.host