Issue Opening New Tab In Multiple Functions In Javascript For Chrome Extension
I am working on a Chrome extension, but for some reason I am able to create a new tab only in a single function and not in multiple functions. Code- function editorial() { chrome
Solution 1:
I think it's because chrome.tabs cannot be used in content scripts.
You should do this instead:
- Send a message to your background page using chrome.runtime.sendMessage
- In your background page, use chrome.runtime.onMessage to catch the message
- Finally use chrome.tabs.create to create a new tab.
Hope this helps
Solution 2:
Well, the problem was due to a missing '}' that was not there. I wasted a lot of time over this and ultimately the bug was such a simple one. Now, I have learnt a lesson, always check ur code twice for proper braces.
Post a Comment for "Issue Opening New Tab In Multiple Functions In Javascript For Chrome Extension"