client/views: fix middle click prevention on buttons for modern browsers

Browsers no longer fire the primary 'click' event for middle clicks.
Old way kept for compatibility as it doesn't hurt anything. All browsers
that support auxclick also have standardized MouseEvent.button values.
This commit is contained in:
Eva 2024-05-06 19:39:56 +02:00
parent 337cdc091e
commit 5e54caf04c

View file

@ -571,6 +571,11 @@ document.addEventListener("click", (e) => {
e.preventDefault();
}
});
document.addEventListener("auxclick", (e) => {
if (e.target.getAttribute("href") === "" && e.button === 1) {
e.preventDefault();
}
});
module.exports = {
htmlToDom: htmlToDom,