I have a question for you, is it possible to create a NavLink like structure in React using only HTML5 and JavaScript?
For example, if we have a homepage.html and a content.html file and I want to go to content.html when an "a" element is clicked, how can I do this without refreshing the page?
CodePudding user response:
Yes you can do it using the history API, you can navigate to different pages without refreshing the page
window.history.pushState('page 2, "page 2 title", "page2.html")
Incase of replace the page you can use window.history.replaceState()
to replace the current page with the new page.
Reference:- https://developer.mozilla.org/en-US/docs/Web/API/History_API/Working_with_the_History_API