Question

I'd like to open links in my chrome extension without having to type chrome.tabs.create and stuff, but why doesn't this work? It doesn't return an error.

$("a").click( function(e) {
  e.preventDefault;
  chrome.tabs.create({ url: $(this).attr("href") });
});

Thanks.

Was it helpful?

Solution

Looks like you have a typo, e.preventDefault is a function, so you should call it with some "()"

But if you just want to open a tab from your extension, simply set a target="_blank" attribute on the anchor tag.

OTHER TIPS

Change:
e.preventDefault;

To:
e.preventDefault();
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top