- title:
- url:
- description:
$(document).ready(function () { function update (info) { $(".title").html(info.title); $(".url").html(info.url); $(".description").html(info.description); } var stateObj = { home: { title: "home", url: "/home", description: "this is home page" }, about: { title: "about", url: "/about", description: "this is about page" }, photos: { title: "photos", url: "/photos", description: "this is photos page" } } $("nav").on("click", "a", {}, function (event) { var state = event.target.getAttribute("href").replace(/\//, ""); event.preventDefault(); history.pushState(stateObj[state], "", event.target.href); update(stateObj[state]); }) window.addEventListener("popstate", function () { var state = history.state; update(state); }); history.pushState(stateObj["home"], "", "/home"); update(stateObj["home"]);})