我必须用 e.target.pathname 处理不同的 URL 结果。
在 Firefox(第 48 节)中:
const x = new URL("/aa/bb/", window.location) // x.pathname is "/aa/bb/"
在 Chrome 中(第 53 节):
const x = new URL("/aa/bb/", window.location) // x.pathname is "/C:/aa/bb/"
我更喜欢x.pathname === "/aa/bb/"
Firefox 给出的 get (没有文件系统符号)。
如何获得适当的、跨浏览器的、相同的结果?也许一些不检查浏览器的聪明、棘手的解决方案?