Call Init from XUL after Page Loads (Firefox add-on)

Posted by mattyboy123 on Stack Overflow See other posts from Stack Overflow or by mattyboy123
Published on 2010-03-18T15:37:59Z Indexed on 2010/03/18 15:41 UTC
Read the original article Hit count: 396

Filed under:
|
|
|
|

Hi all,

I've been working on some code in js/html and it works great. I'm now trying to package it into an add-on for Firefox, and having some issues getting the XUL document correct.

PLAIN OLD HTML/JS

In my html test file between the <head></head> I have:

<script type="text/javascript" src="js/MyCode.js"></script> 

At the end of the test file before the </body> I have:

<script type="text/javascript">MyCode.Static.Init();</script>

FIREFOX ADD-ON: OVERLAY.XUL

In an overlay.xul file in the extension package I have :

        <?xml version="1.0"?>
    <overlay id="mycode"
        xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
        <script type="application/x-javascript" src="chrome://mycode/content/MyCode.js"></script>
        <script>
window.addEventListener("load", function () { gBrowser.addEventListener("load",MyCode.Static.Init,true); }, false);
        </script>
    </overlay>

This does not seem to enter the method, but then again I'm not even sure if I've got the listeners firing properly. Would this be the correct way to duplicate what I was doing in plain old html/js ?

© Stack Overflow or respective owner

Related posts about firefox

Related posts about add-on