Back
Syntax
Study
Editor
Mode:
HTML
CSS
JavaScript
PHP
Reset
Run »
HTML / CSS / JS
// Push new state (changes URL without reload) history.pushState({ page: "about" }, "About", "/about"); // Replace current state history.replaceState({ page: "home" }, "Home", "/"); // Listen for browser back/forward window.addEventListener("popstate", function(e) { console.log("State:", e.state); renderPage(e.state?.page || "home"); }); // Navigate programmatically history.back(); history.forward(); history.go(-2);
Result
Open