views:

30

answers:

2

I'm new to Firefox Add-ons. I want to create a simple Firefox add-ons that append HTML element to a page automatically on document Load. Honestly, I want to add additional BBCODE/smiley toolbar to the any existing textarea.

I got an example of xul (xml) file:

  <popup id="contentAreaContextMenu">
  <!-- some code here -->
 </popup> 



 <!-- toolbar button -->
 <toolbarpalette id="BrowserToolbarPalette">
  <!-- some code here -->
 </toolbarpalette>

 <!-- keyboard shortcut -->
 <keyset>
  <!-- some code here -->
 </keyset>

Is that easy to create a toolbar, popup menu or keyboard shortcut using script above.

The thing i just want to know is, what is the XML code to execute javasript function automatically on page load (without execute command from popup, toolbar or keyboard shortcut)???

I hope you understand with my question and everyone who help me i say thank you.

A: 

You want to capture the 'onload' event. See this response to a related question.

pc1oad1etter
A: 

In your XUL file, you just put a <script> tag inside your <overlay> tag:

<overlay xmlns=...>
 ... other tags here ...
 <script type="application/x-javascript" src="your_script.js"/>
</overlay>

Then inside your_script.js, you can execute whatever Javascript you want.

Here is the MDC tutorial on handling load events.

jeffamaphone
thank you jeffamaphone :)
takien