Manixat Posted April 5, 2013 Share Posted April 5, 2013 (edited) Hello freaks, I've set up an ajax system and I'm in need to use the pushState method. Unfortunately I'm not quite aware of how that works. I went through a bunch of tutorials and examples and still couldn't figure it out. What I have is this $('.tabs > li').click(function(e){ e.preventDefault(); var target = $(this).children('a'), title = target.attr('alt'), // This is equivalent to .html(), I have a translating engine so the html is variable according to the language obj = {url:target.attr('href')}; history.pushState(obj, title, target.attr('href')); }); And this works as long as I don't press the back button, when I do the URL goes back to what it previously was but the page remains the same, why is that? Edited April 5, 2013 by Manixat Quote Link to comment https://forums.phpfreaks.com/topic/276587-history-pushstate/ Share on other sites More sharing options...
haku Posted April 6, 2013 Share Posted April 6, 2013 You need to also implement window.popstate(). history.pushstate() adds to the history, history.popstate() loads your page when you change your history. Quote Link to comment https://forums.phpfreaks.com/topic/276587-history-pushstate/#findComment-1423261 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.