JavaScript: location.href to open in new window/tab?
window.open(
'https://support.wwf.org.uk/earth_hour/index.php?type=individual',
'_blank' // <- This is what makes it open in a new window.
);
If you want to use location.href
to avoid popup problems, you can use an empty <a>
ref and then use javascript to click it.
something like in HTML
<a id="anchorID" href="mynewurl" target="_blank"></a>
Then javascript click it as follows
document.getElementById("anchorID").click();