In the last post, I created an article on How to create a Javascript XPCOM component in 5 minutes”. To make it a little more complete, I will provide the details on how to use the XPCOM Component that you created in this post.
It turns out to be pretty simple once you have followed the instructions from the previous post. The code snippets is shown below.
try {
// this is needed to generally allow usage of components in javascript
netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
var fc = Components.classes['@hungryfools.com/helloworld;1']
.createInstance(Components.interfaces.nsIHelloWorld);
} catch (anError) {
LOG("ERROR: " + anError);
}
Reference: http://developer.mozilla.org/en/docs/How_to_Build_an_XPCOM_Component_in_Javascript
No comments:
Post a Comment