When you create a new tab manually, it is not in your content-script match pattern so it probably doesn't get the message.
If you set up the new tab to open a webpage it would probably work. On Wed, Jan 6, 2010 at 9:04 AM, hok <[email protected]> wrote: > Hi, > I took the simple example from Message Passing tutotial: > http://code.google.com/chrome/extensions/messaging.html > > I want to send a request to an newly created tab, so the > background.html create a tabs.onCreated Listener, and send a request > to the tab: > > background.html > =============== > chrome.tabs.onCreated.addListener(function(tab) { > chrome.tabs.sendRequest(tab.id, {greeting: "hello"}, function > (response) { > console.log(response.farewell); > }); > }); > > in the contentscript.js, there is an Request Listener: > > contentscript.js > ================ > chrome.extension.onRequest.addListener( > function(request, sender, sendResponse) { > console.log(sender.tab ? > "from a content script:" + sender.tab.url : > "from the extension"); > if (request.greeting == "hello") > sendResponse({farewell: "goodbye"}); > else > sendResponse({}); // snub them. > }); > > But it doesn't seem to work, the only time it work is when a click a > link like that: > <a href="http://example.com" target=_blank>cool</a> > not when I click to a new tab. > > Thanks. > > -- > You received this message because you are subscribed to the Google Groups > "Chromium-extensions" group. > To post to this group, send email to [email protected]. > To unsubscribe from this group, send email to > [email protected]. > 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 [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/chromium-extensions?hl=en.
