Back button works only once
back-button, javascript, jquery, pushstate
Solution
Got it!
Line:
window.history.pushState({}, '', href);
should be inside
$(document).on("click", ".galleryLink", function()
I put it inside
changeContent = function(href)
this was my fault... :-)
Problem
I'm working on my page and can't find answer for my issue. I'm using window.history.pushstate, and onpopstate event, here is my code: ``` changeContent = function(href) { window.history.pushState({}, '', href); if (href == "/") { $('#main').load('main.html'); } else { $('#main').html('<iframe id="gallery" src="photos'+href+'/index.html"></iframe>'); } }; $(window).on("popstate", function(e) { changeContent(location.pathname); }); $(document).on("click", ".galleryLink", function() { var href = $( this ).attr( "href" ); changeContent(href) return false; }); ``` i.e. google page -> my main page -> gallery -> back button -> my main page -> back button -> my main page -> back button -> my main page What's going on?