0
votes

I am creating a firefox extension that has a button on the toolbar that will show below custom content that i will set.

I was using a XUL file to create the structure of this content, and i was opening it like this:

var config = {  confirm: false ,
                    username:"",
                    password:""};

window.openDialog( "chrome://myext/content/login.xul",
        "",
        "centerscreen=no,all=no,titlebar=no,chrome=yes,
        toolbar=no,dialog=no,resizable=no,modal=yes",
        config);

Now i'm taking another approach, by using an iframe inside a panel to dynamically use one of multiple xul files as src. Here's the xul:

<toolbarpalette id="BrowserToolbarPalette">
    <toolbarbutton id="myextToolbarIcon"
                   image='chrome://myext/content/images/myext-mini-logo.png'
                   type="panel"
                   class="toolbarbutton-1 chromeclass-toolbar-additional"
                   tooltiptext="myext">
        <panel id="myext-panel"
               type="arrow"
               noautofocus="true"
               consumeoutsideclicks="true"
               onpopupshowing="startscreen(event);"
               level="top">
            <hbox id="myext-panel-container" align="top">
                <iframe id="myext-toolbar-menu" flex="1"/>
            </hbox>
        </panel>
    </toolbarbutton>
</toolbarpalette>

Is there a similar way of sending that "config" variable to the xul file, as it happens with openDialog?

1

1 Answers

1
votes

You cannot really "send" a value to an iframe but you can leave it in a place where the code running inside the iframe can find it - e.g. in an expando property of that iframe tag:

var frame = document.getElementById("myext-toolbar-menu");
frame._myExtConfig = config;
frame.src = "chrome://myext/content/login.xul";

The code running in chrome://myext/content/login.xul can do the following then:

var config = window.frameElement._myExtConfig;

For reference: window.frameElement