JSFiddle - React, Tailwind, and code Playground

by DSDmark

HTML

<button id='root'>
Click
</button>

JavaScript

const root = document.getElementById("root");

const url = "https://stackoverflow.com/questions/75531092/how-to-open-a-url-in-new-tab-and-switch-focus-to-that-tab";

root.addEventListener("click",()=>{
window.open(url, '_blank', 'width=1000,height=1000');
})