<!DOCTYPE html>
<html>
<body>

<p>Click the button to put the new window in the current window.</p>

<button onclick="myFunction()">Try it</button>

<script>
function myFunction() {
    var myWindow = window.open("", "_self");
    myWindow.document.write("<p>I replaced the current window.</p>");
}
</script>

</body>
</html>