xxxxxxxxxx
document.addEventListener('click', function() {
window.open('https://example.com', '_blank');
});
xxxxxxxxxx
<button class="btn btn-success" onclick=" window.open('http://google.com','_blank')"> Google</button>
xxxxxxxxxx
<!-- add target="_blank" to open new tab when link is clicked [in HTML]-->
<a href="YourLink" target="_blank">YourText</a>
xxxxxxxxxx
const element = document.querySelector('#elementId'); // Replace 'elementId' with the actual id of the element
element.addEventListener('click', () => {
window.open('about:blank', '_blank');
});
xxxxxxxxxx
<html>
<body>
<a href="www.google.com" target="_blank">
<button>Click here to open Google</button>
</body>
</html>