I'm using document.open() + write() + close() to create a new page from the client. This works, but it will replace the current history element with the new page, so when the user clicks back they don't see the page they were just on. Example:
- At Home Page
- Click button to navigate to page shown below.
- Click on the click me button on that page.
- Click back - this returns user to home page which I don't want.
I've tried inserting a history element with history.pushState()
but that doesn't work either. It allows the document.open page to have a new url. Clicking back returns the user to the URL of the page I want displayed, but it is still the "New Page".
Full HTML page code below. This type of example doesn't work in fiddles but can be tested locally.
<html>
<body>
<button onclick="clickme()">Click me</button>
<script>
function clickme() {
history.pushState(null, null, "Results/");
document.open("text/html");
document.writeln("New Page");
document.close();
}
</script>
</body>
</html>
Note: Looking for a solution with cross browser support, including the latest Chrome 45 which may has tightened security a bit.