JSFiddle - React, Tailwind, and code Playground

HTML

<button id="button">Open</button>


<!-- the overwriting script --> 
<script>
window.open = false;
</script>

JavaScript

function customOpen() {
	// local variables definitions : 
	var url = "https://stackoverflow.com", iframe, _window;

	// creating an iframe and getting its version of window.open : 
	iframe = document.createElement("iframe");
	document.documentElement.appendChild(iframe);
	_window = iframe.contentWindow;
	
	// storing it in our window object
	window.nativeOpen = _window.open;	
	
	try {
	    window.open(url);
	} catch (e) {
		console.warn(e); // checking that window.open is still broken 
	}
	window.nativeOpen(url);
	
	// deleting the iframe : 
	document.documentElement.removeChild(iframe);
}

document.getElementById("button").addEventListener("click", customOpen);