views:

126

answers:

2

Hi,

My goal is to catch pageloads in my component, insert some javascript into the document and then catch onFocus events. On an event i then want to call the javascript function i injected.

Now i managed to solve most issues, i have the script added to all webpages and i can catch onfocus events. What im not able to do is execute a javascript function from my XPCOM component (C++). In my Internet Explorer BHO i use execScript and it works great. Any ideas?

Currently my workaround is to use setattribute and set the onfocus event of each input element to execute the javascript function, but this is intrusive and overwrites existing onFocus handlers in the webpage. Other ideas are welcome.

Thanks.

A: 

Hi, This the first time I came to know about XPCOM henceforth I am unable to give any input on that. However, I checked in google and found these links. May be they can help you.

1)Create and implement an XPCOM component for the Firefox browser

2) How to Build an XPCOM Component in Javascript

3) XPCOM

priyanka.sarkar
+1  A: 

If you "have the script added to all webpages", the script can take care of both registering a "focus" event listener and taking an appropriate action when the focus event happens.

I'm not sure why you need to call into the content JS from your component.

If you do need to do this, post what you have already tried and in what way it "didn't work".

Nickolay