最新下载
热门教程
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
jquery/js获取当前页面url地址程序代码
时间:2022-11-14 22:02:42 编辑:袖梨 来源:一聚教程网
设置或获取对象指定的文件名或路径。
window.location.pathname
设置或获取整个 URL 为字符串。
window.location.href
设置或获取与 URL 关联的端口号码。
window.location.port
设置或获取 URL 的协议部分。
window.location.protocol
设置或获取 href 属性中在井号“#”后面的分段。
window.location.hash
设置或获取 location 或 URL 的 hostname 和 port 号码。
window.location.host
设置或获取 href 属性中跟在问号后面的部分。
window.location.search
window.location 属性 描述 hash 设置或获取 href 属性中在井号“#”后面的分段。
host 设置或获取 location 或 URL 的 hostname 和 port 号码。
hostname 设置或获取 location 或 URL 的主机名称部分。
href 设置或获取整个 URL 为字符串。
pathname 设置或获取对象指定的文件名或路径。
port 设置或获取与 URL 关联的端口号码。
protocol 设置或获取 URL 的协议部分。
search 设置或获取 href 属性中跟在问号后面的部分。
设置或获取对象指定的文件名或路径。
| 代码如下 | 复制代码 |
设置或获取整个 URL 为字符串。
| 代码如下 | 复制代码 |
|
alert(window.location.href); |
|
设置或获取与 URL 关联的端口号码。
| 代码如下 | 复制代码 |
设置或获取 URL 的协议部分。
| 代码如下 | 复制代码 |
设置或获取 href 属性中在井号“#”后面的分段。
| 代码如下 | 复制代码 |
设置或获取 location 或 URL 的 hostname 和 port 号码。
| 代码如下 | 复制代码 |
设置或获取 href 属性中跟在问号后面的部分。
| 代码如下 | 复制代码 |
如果获取“当前”域名
host = window.location.host;
url=document.domain;
url = window.location.href;
取得完整url路径: 用以下代码可以完整研证结果:
| 代码如下 | 复制代码 | ||||||||||||||||||||
运行如下: thisDLoc = document.location; thisURL = document.URL; thisHREF = document.location.href; thisSLoc = self.location.href; thisTLoc = top.location.href; thisPLoc = parent.document.location; thisTHost = top.location.hostname; thisHost = location.hostname; thisURL: [http://w*eibo*.com/*js/jsweibourl.html] thisHREF: [http://w*eibo*.com/*js/jsweibourl.html] thisSLoc: [http://w*eibo*.com/*js/jsweibourl.html] thisDLoc: [http://w*eibo*.com/*js/jsweibourl.html] thisTLoc: [http://w*eibo*.com/*js/jsweibourl.html] thisPLoc: [http://w*eibo*.com/*js/jsweibourl.html] thisTHost: [weibo.com] thisHost: [weibo.com] thisHPage: [jsweibourl.html] thisUPage: [jsweibourl.html] |
|||||||||||||||||||||
window.location
| 属性 | 描述 |
|---|---|
| hash | 设置或获取 href 属性中在井号“#”后面的分段。 |
| host | 设置或获取 location 或 URL 的 hostname 和 port 号码。 |
| hostname | 设置或获取 location 或 URL 的主机名称部分。 |
| href | 设置或获取整个 URL 为字符串。 |
| pathname | 设置或获取对象指定的文件名或路径。 |
| port | 设置或获取与 URL 关联的端口号码。 |
| protocol | 设置或获取 URL 的协议部分。 |
| search | 设置或获取 href 属性中跟在问号后面的部分。 |
相关文章
- TikTok国际版官网下载入口-安全访问全球版TikTok 12-15
- 新三国志曹操传马超无双试炼四通关攻略 12-15
- 俄罗斯YANDEX引擎官网入口-免登录直达Yandex首页 12-15
- 漫蛙ManWa在线免费阅读入口_漫蛙ManWa官方网页版一键直达 12-15
- 逃离鸭科夫仓库区地窖在哪 仓库区地窖入口位置详情 12-15
- 光与影33号远征队熙艾尔bd玩法:熙艾尔毕业装备与加点思路介绍 12-15