출처: http://groups.google.com/group/netscape.public.mozilla.xpcom/browse_thread/thread/e2ff8c3ffb6323b8/3d2b1991758d6c44

플래그
  2개의 메시지 - 모두 축소

메시지를 게시하실 그룹은 유즈넷 그룹입니다. 이 그룹에 메시지를 게시하시면 인터넷의 모든 사용자가 귀하의 이메일을 볼 수도 있습니다.
답장이 전송되지 않았습니다.
성공적으로 게시되었습니다.
mcbraz...@gmail.com  
프로필 보기
 추가 옵션 2007년9월1일, 오전6시12분
Hello,

I've written a scriptable firefox plugin that is able to receive
messages from JavaScript.  I now need to send messages from the plugin
to JS.  The only way I've found to do this is through the use of the
nsIObserverService using the following code:

    nsCOMPtr<nsIServiceManager> servMan;
    nsresult rv = NS_GetServiceManager(getter_AddRefs(servMan));
    nsCOMPtr<nsIObserverService> observerService;
    rv = servMan->GetServiceByContractID("@mozilla.org/observer-
service;1",

NS_GET_IID(nsIObserverService),

getter_AddRefs(observerService));

    observerService->NotifyObservers(NULL, "Topic", 0);

On the JS side, I will declare an observer that listens for "Topic".

First of all, is this the recommended way to communicate from the
plugin to JS?

Second, when I linked my plugin with xpcom.lib, it no longer gets
instantiated by firefox (I just get a blank window).  I checked the
dependencies on my plugin dll and they are all satisfied.

Any suggestions would be greatly appreciated.

Thanks!


메시지를 게시하려면 그룹에 가입해야 합니다.
메시지를 게시하려면 먼저 해당 그룹에 가입하셔야 합니다.
게시하기 전에 가입 설정 페이지에서 닉네임을 업데이트하십시오.
메시지를 게시할 수 있는 권한이 없습니다.
jenslsoren...@gmail.com  
프로필 보기
 추가 옵션 2007년9월30일, 오후1시37분
On Aug 31, 2:12 pm, mcbraz...@gmail.com wrote:

- 따온 텍스트 보기 -
You can use methods such as JS_CallFunctionName to call java script
from C/C++ if this is what you are looking for. You basically get a
hold of the JS Context and JS Object and then pass in the name of the
function you want to call + the arguments that you want to pass into
this function.
Here are some examples..

http://developer.mozilla.org/en/docs/JS_CallFunctionName

http://www.mozilla.org/js/spidermonkey/tutorial.html

-Jens

AND