【发布时间】:2019-11-19 15:35:52
【问题描述】:
使用 window.location.pathname 页面 https://google.com/home.html 结果将是 "/home.html"
当 url 中不存在文件名时,例如https://google.com/ 结果将是 "/"
inspector 的来源是索引
有没有办法获取当前文件名
【问题讨论】:
标签: javascript pathname
使用 window.location.pathname 页面 https://google.com/home.html 结果将是 "/home.html"
当 url 中不存在文件名时,例如https://google.com/ 结果将是 "/"
inspector 的来源是索引
有没有办法获取当前文件名
【问题讨论】:
标签: javascript pathname
没有。
浏览器无法了解 HTTP 服务器将路径转换为资源的过程。
完全有可能内容是动态生成的,没有“文件”。
【讨论】: