我正在开发一个 safari 扩展,一旦单击按钮,我需要创建一个弹出窗口,我尝试使用 iframe 进行覆盖,但是目标重定向整个页面,因此我被迫使用弹出窗口。
“window.open() JavaScript 方法不能用于从全局 HTML 文件或扩展栏打开新选项卡和窗口。相反,全局文件和扩展栏可以访问 SafariApplication、SafariBrowserWindow 和 SafariBrowserTab 类,其方法和属性允许您使用窗口和选项卡。” (https://developer.apple.com/library/archive/documentation/Tools/Conceptual/SafariExtensionGuide/WorkingwithWindowsandTabs/WorkingwithWindowsandTabs.html#//apple_ref/doc/uid/TP40009977-CH17)
您可以使用safari.application.openBrowserWindow() 打开一个窗口,但我无法找到指定窗口的 URL 或高度/宽度的文档。
有人能指出我正确的方向吗?
I am developing a safari extension and I need to create a popup once you click on a button, I tried an overlay with an iframe but, the destination redirects the whole page so I am forced to use a popup.
"window.open() JavaScript method cannot be used to open a new tab and widow from a global HTML file or an extension bar. Instead, the global file and extension bars have access to the SafariApplication, SafariBrowserWindow, and SafariBrowserTab classes, whose methods and properties allow you to work with windows and tabs." (https://developer.apple.com/library/archive/documentation/Tools/Conceptual/SafariExtensionGuide/WorkingwithWindowsandTabs/WorkingwithWindowsandTabs.html#//apple_ref/doc/uid/TP40009977-CH17)
You can use safari.application.openBrowserWindow() to open a window but I haven't been able to find the documentation to specify a URL or height/width of the window.
Could someone point me in the right direction?
发布评论
评论(1)
我快速浏览了一下 Safari 扩展参考,看起来当您调用 openBrowserWindow 时,您会获得对 SafariBrowserWindow 的引用,该 SafariBrowserWindow 有一个 activeTab 属性,可以为您提供 SafariBrowserTab 引用。 SafariBrowserTab 有一个 url 属性,您可以使用它来指定要加载的 url。
I took a quick look through the Safari Extensions Reference and it looks like when you call openBrowserWindow you get a reference to a SafariBrowserWindow which has an activeTab property that gets you a SafariBrowserTab reference. SafariBrowserTab has a url property that you can use to specify the url you want to load.