I'm developing a Chrome extension that does something when a <td>
tag is clicked in a web page.
Here's some sample code:
HTML:
<table>
<tr>
<td id="mytest"><a href="http://blablabla.com">Foo Bar</a></td>
</tr>
</table>
Javascript:
var myTd = document.getElementById("mytest");
myTd.addEventListener("click", function() {
localStorage["foobar"] = 1;
});
When I click the link, the localStorage
key is set, if I click it with the mouse middle button, it also sets the key (and opens the link in a new tab).
The problem is when I use right-click and "open link in a new tab". In this case the click event doesn't seem to be fired and therefore the localStorage
key will not be set.
Am I missing something? Is there any way to make the right-click -> "open link in new tab" fire the click event?
Please note that I don't want to add the listener to the <a>
node, because of some complications in the real HTML I'm working on.