Chrome extension; open a link from popup.html in a new tab
You should use chrome.tabs module to manually open the desired link in a new tab. Try using this jQuery snippet in your popup.html:
$(document).ready(function(){
$('body').on('click', 'a', function(){
chrome.tabs.create({url: $(this).attr('href')});
return false;
});
});
See my comment https://stackoverflow.com/a/17732609/1340178
I had the same issue and this was my approach:
- Create the popup.html with link (and the links are not working when clicked as Chrome block them).
- Create popup.js and link it in the page:
<script src="popup.js" ></script>
-
Add the following code to popup.js:
document.addEventListener('DOMContentLoaded', function () { var links = document.getElementsByTagName("a"); for (var i = 0; i < links.length; i++) { (function () { var ln = links[i]; var location = ln.href; ln.onclick = function () { chrome.tabs.create({active: true, url: location}); }; })(); } });
That's all, links should work after that.