Safari 弹出窗口可以访问页面 url 吗?
我正在构建一个 Safari 扩展,我想在主工具栏上有一个按钮,用于打开一个弹出窗口。
但问题是: 1) 如何从弹出窗口访问当前选项卡 URL ? 2)如何仅在打开时加载弹出窗口?
I'm building a Safari Extension, and I wanted to have a button on the main toolbar, which opens a popover.
But the problem is:
1) How to access to the current tab URL from the popover ?
2) How to load the popover only when I open it ?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
![扫码二维码加入Web技术交流群](/public/img/jiaqun_03.jpg)
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
1) 您可以从注入脚本 (window.location.href) 访问当前选项卡 url,只需发送到注入脚本消息、获取 url 并将回调发送到弹出窗口。
2)您必须在单击工具栏按钮上动态创建弹出窗口。然后将弹出窗口分配给工具栏项。并显示它
在使用弹出框执行所有操作之后,您必须取消分配它。
检查弹出窗口的可见性,将 null 分配给工具栏项目并删除弹出窗口
1) You can access to the current tab url from injected scripts (window.location.href), just send to injected script message, get url and send callback to popover.
2) You have to create popover dynamically on click toolbar button. Then assign popover to toolbar item. And show it
After all actions with popover you must deallocate it.
Check visibility of popover, assign null to toolbar item and remove popover
这是一个老问题了。
但我最近想做这个。您可以使用以下命令从 popover.html 中访问选项卡 url:
This is an old question.
But I recently wanted to do this. You can access the tabs url from inside your popover.html with: