Skip to content Skip to sidebar Skip to footer

Chrome Extension: Stack Trace: Typeerror: Cannot Read Property 'selectedtext' Of Undefined

my contentscript.js: chrome.runtime.onMessage.addListener(function(request, sender, sendResponse) { if (request.ask === 'selectedtext'){ sendResponse({selectedtext: window.

Solution 1:

Well your error means that you're getting undefined as your response. i.e no data is coming back from the context page.

Your content.js looks fine, I think the most likely thing is there is no content script communicating from the other end. Put a console.log in your content script and make sure that's being hit.

You may just need to refresh the page that you're communicating with as the content script may not be the current one?

Post a Comment for "Chrome Extension: Stack Trace: Typeerror: Cannot Read Property 'selectedtext' Of Undefined"