首页
学习
活动
专区
工具
TVP
发布
精选内容/技术社群/优惠产品,尽在小程序
立即前往
您找到你想要的搜索结果了吗?
是的
没有找到

JS获取当前网址信息

通过window.location对象获取对应属性 1、设置或获取对象指定文件名或路径(pathname) window.location.pathname 2、设置或获取整个 URL 为字符串(href...) window.kk 3、设置或获取URL 关联端口号码(port) window.location.port 4、设置或获取 URL 协议部分(protocol) window.location.protocol...设置或获取 href 属性中在井号“#”后面的分段(hash) window.location.hash 设置或获取 location 或 URL hostname 和 port 号码(host)...(url.lastIndexOf('=')+1, url.length); 用来得到当前网页域名 document.domain 注意: 1、获取过后直接使用substring方法截取我们需要信息。...2、通过正则表达式准确获取我们需要参数。

13.7K30
领券