【问题标题】:JS how to know current file name when is only domainJS如何知道当前文件名时只有域
【发布时间】:2019-11-19 15:35:52
【问题描述】:

使用 window.location.pathname 页面 https://google.com/home.html 结果将是 "/home.html"

当 url 中不存在文件名时,例如https://google.com/ 结果将是 "/"

inspector 的来源是索引

有没有办法获取当前文件名

【问题讨论】:

    标签: javascript pathname


    【解决方案1】:

    没有。

    浏览器无法了解 HTTP 服务器将路径转换为资源的过程。

    完全有可能内容是动态生成的,没有“文件”。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2014-07-25
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-07-17
      • 1970-01-01
      • 1970-01-01
      • 2013-02-15
      相关资源
      最近更新 更多