I want to use an image as a button (setting.png), and onclick open a URL in a new tab.
My popup.html:
<html>
<head>
<style>
</style>
</head>
<body>
<a href = "http://google.com" id="link"><img src="setting.png" width="30px" height="auto"></a>
<script src ="javascript.js"></script>
</body>
</html>
manifest.json:
{
"manifest_version": 2,
"name": "",
"options_page": "options.html",
"background": {
"scripts": [
"background.js"
]
},
"description": "",
"version": "1.5",
"offline_enabled": true,
"browser_action": {
"default_icon": "icon.png",
"default_popup": "popup.html"
},
"icons": { "16": "icon16.png",
"32": "icon32.png",
"48": "icon48.png",
"64": "icon64.png",
"128": "icon128.png" },
"permissions": [
"activeTab",
"https://ajax.googleapis.com/",
"storage",
"tabs"
]
}
javascipt.js:
window.addEventListener('click',function(e){
if(e.target.href!==undefined){
chrome.tabs.create({url:e.target.href})
}
})
So when I click on the image I want to open the URL in a new tab. Thanks!