3

Say a webpage has a function like:

function abc (){
return 'abc';
}

How would I execute and receive the return value of that function from my extension? I've tried this, no dice:

var s = getBrowser.contentWindow.abc();

Thanks in advance!

mattsven
  • 22,305
  • 11
  • 68
  • 104
  • possible duplicate of [How do I execute a page-defined JavaScript function from a Firefox extension?](http://stackoverflow.com/questions/151555/how-do-i-execute-a-page-defined-javascript-function-from-a-firefox-extension) – Gabriele Petrioli Jul 24 '10 at 18:47
  • The answer to that question (the one that was at Google Groups) doesn't work for me. – mattsven Jul 24 '10 at 18:50

2 Answers2

0

I think that if you want to do this without major security holes, you need to be using XPCSafeJSObjectWrapper, but I'm having trouble finding good documentation on it. https://developer.mozilla.org/en/XPConnect_wrappers has a little bit. (It might be that it happens automatically when doing the above, but I'm not sure.)

David Baron
  • 920
  • 4
  • 5
-1

I think I've solved my own problem with:

getBrowser().contentWindow.wrappedJSObject.funcFromPage();
mattsven
  • 22,305
  • 11
  • 68
  • 104