Hi guys,
I am learning how to make chrome add-on and was just checking how
message passing thing works, but I am facing a problem in making it
work. I am taking the simple example from 
http://code.google.com/chrome/extensions/messaging.html
page but it's not working.

I want to My background.html page to send a request to content.js file
only when someone click on the browser button. for that i have done
something like this

background.html page
======================
<html>
<script>
  function getPageandSelectedTextIndex() {
  chrome.tabs.getSelected(null, function(tab) {
                chrome.tabs.sendRequest(tab.id, {greeting: "hello"}, function
(response) {
                        console.log(response.farewell);
                });
        });
        }
chrome.browserAction.onClicked.addListener(function(tab) {
        getPageandSelectedTextIndex();
});
</script>
</html>

content.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.
  });

i was thinking message will be logged in console when i will click on
the button. but i m not able to see any message there.

can anybody please tell me what's wrong going on here ??

Thanks in advance
-- 
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