用js获取当前路由信息的方法
2024-10-20 04:39:48
1,设置或获取对象指定的文件名或路径。
alert(window.location.pathname)
2,设置或获取整个 URL 为字符串。
alert(window.location.href);
3,设置或获取与 URL 关联的端口号码。
alert(window.location.port)
4,设置或获取 URL 的协议部分。
alert(window.location.protocol)
5,设置或获取 href 属性中在井号“#”后面的分段。
alert(window.location.hash)
6,设置或获取 location 或 URL 的 hostname 和 port 号码。
alert(window.location.host)
7,设置或获取 href 属性中跟在问号后面的部分。
alert(window.location.search)
8,获取变量的值(截取等号后面的部分)
var url = window.location.search;
// alert(url.length);
// alert(url.lastIndexOf('='));
var loc = url.substring(url.lastIndexOf('=')+1, url.length);
9,用来得到当前网页的域名
var domain = document.domain;
stay hungry stay foolish!
最新文章
- kettle启动“Error: could not create the Java Virtual Machine”
- 如何优雅的使用vue+vux开发app -01
- android学习笔记37——Menu资源
- 数据库:mongodb与关系型数据库相比的优缺点
- JDK - Tomcat - Eclipse - JSP - Servlet 配置运行全攻略
- php整理(一):变量和字符串
- 犯罪构成三层次记忆口诀 zt
- SQL 树结构统计数据
- 添加PDF文件对照度的粗浅原理,及方法
- zoj 3204 Connect them
- java_web学习(四) 二维表的制作(初步接触MVC)
- 通过编程为Outlook 2007添加邮件规则
- 浏览器解析js的顺序
- Java 线程池(ThreadPoolExecutor)原理分析与使用
- [Swift]LeetCode1017. 负二进制转换 | Convert to Base -2
- 2、Docker基础用法
- C# 树状图
- SQL 事务 begin tran、commit tran、rollback tran 的用法
- Proftpd 服务器安装配置
- MediaPlayer音乐播放器、上一首、下一首、播放、停止、自动下一首、进度条