开发者

Firefox Add-ons, How to execute javascript function onLoad?

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 automatical开发者_JS百科ly 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.


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.


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

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜