Re: Old question, Embed javascript extension

Benjamin Smedberg <[email protected]>
Newsgroups gmane.comp.mozilla.devel.embedding
Message-ID <[email protected]>
On 11/6/10 8:52 AM, Xijing Dai wrote:

> I have a questions about javascript extension after you embeding the
> xulrunner.
>
> so far, i found that if you want to write a extension to the
> javascript, u have to create a component, isn't it?

Could you perhaps be more specific? By "extension to the javascript", do you 
mean adding some property to the DOM which every web page sees?

Also, how are you setting up your application? Are you writing a Firefox 
extension? Or a XULRunner application? Or using some embedding API which 
doesn't use XUL?

Starting with Firefox 4/Mozilla 2, you can use the 
content-document-global-created notification to watch and modify the DOM of 
pages as they load. This is the recommended way to add special properties to 
the DOM. See https://developer.mozilla.org/en/Observer_Notifications#Windows 
for details.

> secondly, i am new to xulrunner, i found it's hard to execute a
> javascript code from C++, any directions?

The normal way to do this is via an XPCOM component. The IDL interface 
defines a method which can call C++<->JS.

--BDS
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.