javascript - How to open a link in a new tab when clicking on an image in a chrome extension? -


i made simple chrome extension that, when clicked, has dropdown menu has row of icons. possible set when icon clicked, opens respective website in new tab?

(note: have tried make refer link in popup.html file, if click on icon, doesn't anything.)

any help, suggestions or advice appreciated, thanks!

you need assign click handler icon executes following:

chrome.tabs.create({url: websitetoopen}); 

if want open in background without closing popup, 1 more parameter required:

chrome.tabs.create({url: websitetoopen, active: false}); 

do note "tabs" permission not needed this.

this example chrome docs shows how assign click hanlder in way that's compatible chrome extensions (onclick attribute not work)


Comments