数码资讯
js获取当前页的url信息。
1,将整个URL设置为字符串: window.location.href 2,设置或获取与URL相关联的端口号: window.location.port 三.设置或获取URL的协议部分 window.location.protocol 4、设置或获取部分的问号后面的href属性 window.lo
选购提示
关注价格、性能、续航、售后和真实使用场景,理性比较后再下单。
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
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
声明:本文内容用于数码产品信息整理与选购参考,具体价格、库存、售后政策以官方渠道和电商页面实时信息为准。