17 lines
465 B
JavaScript
17 lines
465 B
JavaScript
export default function() {
|
|
const elements = document.querySelectorAll('[data-href]');
|
|
|
|
elements.forEach(e => {
|
|
const href = e.dataset.href
|
|
e.addEventListener('click', () => {
|
|
window.location.href = href;
|
|
});
|
|
e.addEventListener('auxclick', (evt) => {
|
|
if (evt.button == 1) {
|
|
// Middle click was pushed
|
|
window.open(href, '_blank')
|
|
}
|
|
});
|
|
});
|
|
}
|