views:

76

answers:

1

I'm fairly new to JS and XUL so please bear with me if this is a noob query :-)

I am developing an extension for firefox which performs a custom action when a toolbar button (created by me) is clicked. I have been able to create the button using mozilla examples but what I have seen is that even when the extension is installed successfully (and I restart firefox to complete the changes) the button needs to be added manually to the toolbar. After this it can be used as required and even on subsequent launches of FF it stays in the toolbar.

I wanted to know if there is a way by which the button will be auto-loaded when the extension is successfully installed. My XUL script looks like so:

<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/css"
  href="chrome://custombutton/content/button.css"?>

<!DOCTYPE overlay >
<overlay id="custombutton-overlay"
  xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"&gt;

<script type="application/javascript"
  src="chrome://custombutton/content/button.js"/>

<!-- Firefox -->
<toolbarpalette id="BrowserToolbarPalette">
  <toolbarbutton id="custom-button-1"/>
  </toolbarpalette>

<!-- button details -->
<toolbarbutton id="custom-button-1"
  label="Custom"
  tooltiptext="My custom toolbar button"
  oncommand="CustomButton[1]()"
  class="toolbarbutton-1 chromeclass-toolbar-additional custombutton"
  />

</overlay>
+1  A: 

You'll need to write some javascript code to accomplish that: Adding button by default. Take a look at Adding toolbar buttons to existing toolbars too.

Fábio
@Fabio: Thank you!
Sagar V