troubleshooting Question

Chrome extension: messaging

Avatar of CrAppl
CrAppl asked on
JavaScriptWeb BrowsersScripting Languages
3 Comments1 Solution228 ViewsLast Modified:
Hey!

This is not a real extension, I'm just screwing around to see how this works.

Basically, in my background.html page I have this:
function test3()
{
alert("blah3");
chrome.extension.sendRequest('test2');
}

Open in new window


and in my popup.html page, I have this:
chrome.extension.onRequest.addListener(
    function(request, sender, sendResponse) {
        if(request.function == "test3") {
           alert("Works!");
           }
    }
);

Open in new window


But the alert "Works" never seems to be called... I even tried to replace the

 alert("Works!");

Open in new window


with
call_test_function();

Open in new window


which in turn has an alert()... but that does not get called either.

Mind telling me where I went wrong? And giving me the code to make my little example work?

I even reversed the pages so that the code from background is in popup and the code from popup is in background... does not work :(

Thanks! R
ASKER CERTIFIED SOLUTION
FireAnICE

Our community of experts have been thoroughly vetted for their expertise and industry experience.

Join our community to see this answer!
Unlock 1 Answer and 3 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 3 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros