crop_rotate
Run
<html> <head> </head> <body> <h1 id="data">JavaScript SPA Single page application Syntax</h1> <p id="description"></p> <input type="button" value="Change URL" id="myInp"> <script> let myInp = document.getElementById("myInp"); let description = document.getElementById("description"); let data = document.getElementById('data'); const state = { "title": "Welcome to My SPA", "description": "This is a simple single page application built with JavaScript from close tag" } myInp.addEventListener('click',()=>{ history.pushState(state,'') data.innerText = "H1 changed to : " + history.state.title description.innerText = "H1 changed to : " + history.state.description window.history.pushState({urlPath:'/tutorial/javascript/javascript-spa-single-page-application/javascript-spa-single-page-application-object'},"",'/tutorials') }) </script> </body> </html>
JavaScript SPA Single page application Syntax