views:

193

answers:

1

I would like to know how to implement a dialog that show up when you first start Firefox to ask the user to enter some input. This input will be stored somewhere temporarily, and should be used later on by the plugin when required. I have full understand of how to implement firefox plugin (this includes understanding of XUL and Javascript), so no need for full plugin example. The specific question is how to show a dialog when firefox start that ask for input, and how to store the input in a temporary storage.

Any help would be appreciated.

+2  A: 

Add an event listener to your overlay.xul:

<window>
  <script type="text/javascript">
    var your_func = function (e) {
      var pref = window.prompt ("Your name:","");
    }
    window.addEventListener ("load", your_func, false);
  </script>
</window>

The your_func() will be called, whenever a new window (not a new tab) is loaded. If it should only be on start-up, you'll have to make an additional test. You find details here: developer.mozilla.org

For persistence you could store the found value as a preference: Preference Code Snippets. It would be useful then, to check in your_func, if such a preference exists, before opening the prompt.

Instead of a plain prompt, you could do the following:

window.open ("chrome://my-plugin/content/prompt.xul", "MyWindow", "chrome,modal,alwaysRaised,centerscreen");

The magic lies in the "modal" value in the third parameter.

Cheers,

Boldewyn