I need to replace content in the same window but after setting content in new window address bar didn't change to new one, so I tried to set with a pushState method. But browsers go back button doesn't load previous content it's only change url
const newWindow = window.open("http://localhost:4040/mywebsite/newPath", "_self");
newWindow.document.write("<p>I replaced the current window.</p>");
newWindow.history.pushState(null, "", "http://localhost:4040/mywebsite/newPath");