I am working on a website with Wordpress where posts are to be loaded with AJAX while changing the url to the actual permalink of the post. Like how pinterest works. The AJAX loaded content is displayed in a modal box. I use
window.history.pushState(stateObj, title, url) to change the url of the browser to the post's permalink. Now my problem is:
When the modal box closes, I want to go to the previous url without reloading the page.
e.g. I am on the homepage (http://example.com), then i click a post, modal box opens with the post content fetch through AJAX and the url become (http://example.com/post1). When the modal box closes, I would like the url to go back to (http://example.com) without actual page reload. So basically only to the previous state.