Loading Jscript files into Firefox extension

Posted by colon3l on Stack Overflow See other posts from Stack Overflow or by colon3l
Published on 2010-05-15T16:16:05Z Indexed on 2010/05/15 16:24 UTC
Read the original article Hit count: 290

Hi !

Let's get directly to the problem :

I'm actually doing a firefox extension in which i would like to implement the jWebsocket API in order to build a small chat. I got my main script file, named test.js, and the jWebsocket lib into a js folder. Just for you to know, this is my first firefox extension ever.

So in my XUL file I got this (for the script part only of course, the interface code is not shown) :

    <overlay id="test-overlay" xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
  <script type="application/x-javascript" src="chrome://test/content/test.js" />
  <script type="application/x-javascript" src="chrome://test/content/js/jwebsocket.js" />

jwebsocket.js being the file I need to call according to jWebsocket website.

In my main script file test.js I start with :

if (jws.browserSupportsWebSockets()) 
{
  jWebSocketClient = new jws.jWebSocketJSONClient();
} 
else 
{
  var lMsg = jws.MSG_WS_NOT_SUPPORTED;
  alert(lMsg);
}

jws being the namespace created into the jwebsocket.js file.

Of course I've got the required stand-alone server running in background, and working.

So from what I understood looking on various websites, is that if a js file is loaded into the javascript allocated memory space (with the tag), all namespace/function should be available between each file. But this was mostly for HTML-oriented issues, so I'm not sure if it applies to XUL/Firefox environment.

But the script keep failing at the first jws call.

Any ideas on what goes wrong here ? I'm stuck for 2 days now :/

© Stack Overflow or respective owner

Related posts about firefox

Related posts about extension