This is basically just a JavaScript design, you can use apply/call to let
the function return what you need, for instance:


popup.html:

>   var bkg = chrome.extension.getBackgroundPage();

  bkg.test(function(result) {

    alert(result);

  });


background.html:

>   function test(func) {

    func.apply(this, ['bar']);

  }


If you don't like to send an array of parameters you can use call to call
the args individually.

background.html:

>   function test(func) {

    func.call(this, 'bar');

  }


You should see an alert. For more information, refer to
https://developer.mozilla.org/En/Core_JavaScript_1.5_Reference/Objects/Function/Apply

-Mohamed Mansour


On Thu, Jan 21, 2010 at 5:32 PM, Erez <ere...@gmail.com> wrote:

> Hi,
>
> How can I get a reference to the popup page so I can call it from the
> getBackgroundPage()?
> I've seen why way that iterates the views until it finds one with a
> view that contains a field or function that only the popup page has.
> Is there a better way?
>
> I would like to have the popup call functions on the background and
> specify a callback to return to once the function on the background is
> complete.
>
> Am I missing something?
>
> Thanks,
> Erez
>
> --
> You received this message because you are subscribed to the Google Groups
> "Chromium-extensions" group.
> To post to this group, send email to chromium-extensi...@googlegroups.com.
> To unsubscribe from this group, send email to
> chromium-extensions+unsubscr...@googlegroups.com<chromium-extensions%2bunsubscr...@googlegroups.com>
> .
> For more options, visit this group at
> http://groups.google.com/group/chromium-extensions?hl=en.
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Chromium-extensions" group.
To post to this group, send email to chromium-extensi...@googlegroups.com.
To unsubscribe from this group, send email to 
chromium-extensions+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/chromium-extensions?hl=en.

Reply via email to