什么样的信息服务工作者对自己有什么?

发布于 2025-02-13 17:28:50 字数 256 浏览 0 评论 0原文

我想问“如何从内部服务人员那里获得服务工作者的位置?”但是我发现了这个问题获取服务工作者ID或从服务工作者中的日期发现任何有用的东西。

因此,我的问题是从工人内部有关于服务人员的任何信息。或要有任何元数据,我需要向工人发布一条消息。

我对工人的URL或安装工人安装的网站的URL感兴趣,因为我需要此URL来路由工人内部。

I wanted to ask "How to get the location of the service worker from the inside service worker?" but I've found this question get service worker id or date from within service worker, I was looking at the spec but didn't found anything useful.

So my question is are there any information about the service worker from inside the worker. Or to have any metadata I need to post a message to the worker.

I'm interested in the URL of the worker or the URL of the website where the worker was installed since I need this URL for routing inside the worker.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

想你只要分分秒秒 2025-02-20 17:28:50

看来,服务人员内部有一个位置指向工人文件名的URL。

到达工人安装的根路径(我需要的)您可以使用:

const root_url = location.pathname.replace(/[^\/]+$/, '');

It seems that there is a location inside service worker that points to the URL of the worker filename.

To the path of the root where worker was installed (which is what I need) you can use:

const root_url = location.pathname.replace(/[^\/]+$/, '');
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文