chrome.tabs.executeScript to get returned value from javascript code or file

2,807 views
Skip to first unread message

jwvai316

unread,
Apr 6, 2010, 10:36:45 PM4/6/10
to Chromium-extensions
Hi,

on chrome.tabs.executeScript(integer tabId, object details,
function callback)

Can the javascript code or file on the object details return value?

if it can, then how do I get the value returned by the javascript code
or file inside object details
and use the value in the callback function?

Thanks.

Arne Roomann-Kurrik

unread,
Apr 7, 2010, 1:50:27 PM4/7/10
to jwvai316, Chromium-extensions
It sounds like you want the code you execute using chrome.tabs.executeScript to send a message back to the background page.  If this is correct, you can do this using message passing - set up a listener in the background page and call chrome.extension.sendRequest from your code snippet.  See http://code.google.com/chrome/extensions/messaging.html for more detailed information about how this works.

Cheers,
~Arne


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


jwvai316

unread,
Apr 12, 2010, 1:35:51 AM4/12/10
to Chromium-extensions
Thanks Arne,

I know understand that the message passing does not work as call and
return to the caller. It is more like send the request (in this case
the value to be returned) and add listener to get the request. thus,
allowing other page to get the value too..

Thanks.

On Apr 8, 3:50 am, Arne Roomann-Kurrik <kur...@chromium.org> wrote:
> It sounds like you want the code you execute using chrome.tabs.executeScript
> to send a message back to the background page.  If this is correct, you can
> do this using message passing - set up a listener in the background page and

> call chrome.extension.sendRequest from your code snippet.  Seehttp://code.google.com/chrome/extensions/messaging.htmlfor more detailed


> information about how this works.
>
> Cheers,
> ~Arne
>
>
>
> On Tue, Apr 6, 2010 at 7:36 PM, jwvai316 <jwvai...@gmail.com> wrote:
> > Hi,
>
> > on chrome.tabs.executeScript(integer  tabId, object  details,
> > function  callback)
>
> > Can the javascript code or file on the object details return value?
>
> > if it can, then how do I get the value returned by the javascript code
> > or file inside object details
> > and use the value in the callback function?
>
> > Thanks.
>
> > --
> > 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...@chromium.org.


> > To unsubscribe from this group, send email to

> > chromium-extensions+unsubscr...@chromium.org<chromium-extensions%2Bunsubscr...@chromium.org>

Reply all
Reply to author
Forward
0 new messages