简体   繁体   中英

accessing javascript object within xul

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. Ie 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.

You can load the js file using this code:

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

This is a like appending a tag in your document but in a more cleaner way.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM