开发者

For a FireFox Overlay how do you specify what Gecko/FireFox version(s) to apply it to?

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="commonD开发者_运维技巧ialogOnLoad(); 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.


I 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


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:

<overlay id="myOverlay"
    xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">

    <script type="text/javascript"><![CDATA[
        window.addEventListener("load", function()
        {
            // Your code here
        }, false);
    ]]></script>
</overlay>

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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜