对于 FireFox Overlay,如何指定要应用它的 Gecko/FireFox 版本?
有一个作为应用程序一部分安装的插件,该插件需要使用不同的覆盖层,具体取决于在修改界面时使用的 FF 版本。
我发现 https://developer.mozilla.org/en/Bundles 指定不同的文件,但这似乎只涵盖哪个操作系统/位数。
有没有办法指定覆盖仅适用于特定版本的 UI?
IE。这适用于 FF3.6 及更早版本,但会破坏 FF4。
<overlay id="myOverlay"
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
<dialog id="commonDialog" onload="commonDialogOnLoad(); myLoad();"
ondialogaccept="myAccept(); return commonDialogOnAccept();">
这是针对域登录和 FTP 登录对话框,因此使其更具体的想法也可能有所帮助。
Have a pluggin that is installed as part of an app, the pluggin needs to use different overlays depending on what version of FF is being used as it modifies the interface.
I found https://developer.mozilla.org/en/Bundles to specify different files but this only seems to cover which OS/bitness.
Is there a way to specify that an overlay only applies to particular versions of the UI?
ie. This works for FF3.6 and earlier but breaks FF4
<overlay id="myOverlay"
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
<dialog id="commonDialog" onload="commonDialogOnLoad(); myLoad();"
ondialogaccept="myAccept(); return commonDialogOnAccept();">
This is aimed at the Domain Login and the FTP Login dialogs, so an idea on making it more specific could help too.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
从技术上讲,MatrixFrog 的答案是正确的,您可以在 chrome.manifest 文件中使用标志。然而,你最好考虑这样一个事实:你的代码破坏了 Firefox 4 的警告——不应该使用这种方法,它很可能破坏浏览器功能。另外,如果第二个扩展尝试做同样的事情怎么办?您应该扩展内置功能,而不是覆盖它。您的目标显然是在加载公共对话框时运行您自己的代码。请考虑以下方法:
这解决了两个问题。其一,您不再需要重写“load”事件的现有处理程序 - addEventListener 允许注册任意数量的事件处理程序,这与 onload 属性/属性不同。另一个问题:您将函数 myLoad() 添加到公共对话框的全局命名空间中。如果 Firefox 代码或其他扩展决定将来使用相同的函数名称,将会出现麻烦。上面的代码通过使用匿名函数完全避免了这个问题——不能有命名冲突。
Technically, the answer by MatrixFrog is correct, you can use flags in your chrome.manifest file. However, you better consider the fact that your code breaks Firefox 4 a warning - this approach should not be used, it is likely to break browser functionality. Also, what if a second extension tries to do the same thing? You should extend built-in functionality, not overwrite it. Your goal is apparently to run your own code when the common dialog loads. Please consider the following approach:
This solves two problems. For one, you no longer need to override the existing handler for the "load" event - addEventListener allows registering as many event handlers as you want, unlike onload attribute/property. The other problem: you were adding a function myLoad() to the global namespace of the common dialog. If Firefox code or some other extension decides to use the same function name in future there will be trouble. The code above completely avoids this problem by using an anonymous function - there can be no naming conflicts.
我自己还没有这样做过,但我认为您可以使用
chrome.manifest
文件中的标志来实现此效果。请参阅https://developer.mozilla.org/en/Chrome_Registration#Manifest_flagsI haven't done this myself, but I think you can accomplish this effect using flags in your
chrome.manifest
file. See https://developer.mozilla.org/en/Chrome_Registration#Manifest_flags