【发布时间】:2018-04-26 14:31:13
【问题描述】:
如何获取服务工作者的“获取”事件正在服务的页面的完整 URL?
“self.location”属性似乎只引用站点的根 URL。例如,如果页面https://example.com/folder/pagename.html 正在执行服务工作者正在拦截的提取,则服务工作者的“self.location”属性返回“https://example.com”。
event.currentTarget.location 和 event.explicitOriginalTarget.location、event.originalTarget 和 event.target 都返回 service worker .js 文件的 URL。
如何获取触发 fetch 事件的页面的完整 URL?
【问题讨论】:
标签: javascript url offline service-worker