0

ERROR: "chromeWindow.state" is undefined here

Can you put me in the right direction?

chrome.runtime.onMessage.addListener(function(message,sender,sendResponse) 
{
  chrome.windows.get(sender.tab.windowId, function(chromeWindow) {
    // chromeWindow is DEFINED HERE
    console.log('sending to contentscript :', chromeWindow.state);
  });
  // chromeWindow.state is UNDEFINED
  sendResponse(**chromeWindow.state**);
});
2
  • It looks like the scope is not right. pluralsight.com/guides/… Commented Aug 29, 2018 at 20:28
  • 1
    Function parameters exist only within the scope of the function to which they are passed. You should read more about how functions in JavaScript work. Commented Aug 29, 2018 at 20:28

1 Answer 1

0
chrome.runtime.onMessage.addListener(function(message,sender,sendResponse) 
{
  chrome.windows.get(sender.tab.windowId, function(chromeWindow) {
      sendResponse(chromeWindow.state);
  });
});
Sign up to request clarification or add additional context in comments.

2 Comments

this is how I did it at first ... maybe there is another issue ...will add full code.
ok the duplicate topic pointed me in the right direction... it was a synching issue. I added : return true; developer.chrome.com/apps/messaging

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.