Pregunta

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.

¿Fue útil?

Solución

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.

Otros consejos

Change:
e.preventDefault;

To:
e.preventDefault();
Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top