如何用js获取当前打开的页面的路径
答案:4 悬赏:80 手机版
解决时间 2021-03-21 06:34
- 提问者网友:练爱
- 2021-03-20 14:24
如何用js获取当前打开的页面的路径
最佳答案
- 五星知识达人网友:酒者煙囻
- 2021-03-20 15:41
设置或获取对象指定的文件名或路径。
alert(window.location.pathname)
设置或获取整个 URL 为字符串。
alert(window.location.href);
设置或获取与 URL 关联的端口号码。
alert(window.location.port)
设置或获取 URL 的协议部分。
alert(window.location.protocol)
设置或获取 href 属性中在井号“#”后面的分段。
alert(window.location.hash)
设置或获取 location 或 URL 的 hostname 和 port 号码。
alert(window.location.host)
设置或获取 href 属性中跟在问号后面的部分。
alert(window.location.search)
alert(window.location.pathname)
设置或获取整个 URL 为字符串。
alert(window.location.href);
设置或获取与 URL 关联的端口号码。
alert(window.location.port)
设置或获取 URL 的协议部分。
alert(window.location.protocol)
设置或获取 href 属性中在井号“#”后面的分段。
alert(window.location.hash)
设置或获取 location 或 URL 的 hostname 和 port 号码。
alert(window.location.host)
设置或获取 href 属性中跟在问号后面的部分。
alert(window.location.search)
全部回答
- 1楼网友:神鬼未生
- 2021-03-20 17:15
可以输出当前的路径。
- 2楼网友:佘樂
- 2021-03-20 16:29
如果你的的web页面是在服务器,js是获得不了的php 是通过$_SERVER来获得的,asp net jsp都是用自己的函数获得,如果你在你本地测试 可以是楼上的
我要举报
如以上回答内容为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
点此我要举报以上问答信息
大家都在看
推荐资讯