<html>
<head>
<script src="https://code.jquery.com/jquery-3.2.1.min.js" crossorigin="anonymous"></script>
<script>
var win;
$(document).on('click', '#okGoogle', function (event) {
event.preventDefault();
url = "http://www.google.com/";
if (!win) {
win = window.open(url, '_blank');
}
else {
win.focus();
}
});
</script>
</head>
<body>
<button id="okGoogle">Ok Google</button>
</body>
</html>
This code works fine. But when newly opened window is closed, code does not open it again. Any suggestions?