On Wed, Jun 17, 2009 at 1:16 AM, Shane Tomlinson<[email protected]> wrote:

> chrome.tabs.getSelected( undefined, function( in_objTab ) {
>            if( in_objTab.postMessage )
>            {
>                console.log( 'can post message' );
>            } // end if
>            else
>            {
>                console.log( 'cannot post message' );
>            } // end if
>    } );

postMessage() is the way to do this, but the tab object doesn't
(currently) have a postMessage() method. What made you think it does?
If there were some docs that implied this, I'm sorry, we'll definitely
fix those.

Anyway, the way to do this is to setup a content script to be injected
into the pages you're interested in. For more detail on that, take a
look at: 
http://dev.chromium.org/developers/design-documents/extensions/content-scripts

Once the content script is injected, if you want to talk to it, the
content script must initiate the communication. Right now, we don't
have a way for the extension to do so, though we would like to add
one. So the content script does something like:

var port = chrome.extension.connect();
port.onMessage.addListener(function(reply) {
  alert("reply: " + reply);
});
port.postMesage("hello there!");

To be prepared to get messages, the extension does:

chrome.self.onConnect.addListener(function(port) {
  port.onMessage.addListener(function(message) {
    alert("got message: " + message);
    port.postMessage("yoooes");
  });
});

>  Am I being thick, unresourceful, not looking in the right place, all
> three?

No, the docs are not super great right now while we're in development.

HTH,

- a

--~--~---------~--~----~------------~-------~--~----~
Chromium Discussion mailing list: [email protected] 
View archives, change email options, or unsubscribe: 
    http://groups.google.com/group/chromium-discuss
-~----------~----~----~----~------~----~------~--~---

Reply via email to