0

I have a series of javascript objects that I would like to make accessible from a xul page. I have looked at the XUL school tutorial on this and am getting nowhere.

Basically, I am writing a firefox extension that opens up a .xul page in a new tabbed window. My objects are initialized with certain data and I then want to be able to take in, validate, and store user information into javascript objects. Data doesn't have to be persistent. I.e. when the page closes, it goes away.

I already have my javascript objects coded up in a separate .js file, but I can't find any good, simple tutorial on how to access them from within the xul file.

Any help you all could give would be appreciated.

4

1 回答 1

0

您可以使用以下代码加载 js 文件:

Components.utils.import( 'resource://gre/modules/Services.jsm' );
Services.scriptloader.loadSubScript( YOUR_JS_FILE );

这类似于在文档中添加标签,但方式更简洁。

于 2012-10-17T18:52:03.027 回答