I am using this type of line in an JS response
if (history && history.pushState){ history.pushState(null, null, '<%=j home_path %>'); }
but when I click back
in the browser, I see the JS code of the response instead of the previous page.
Is there a way to make the back button work so it would re-request the page of the last url (before home_path
as pushStated in?
Update:
I've found this.. it seems other have the same issue with.. History.js doesn't fix it either
So to confirm some of the comments there.. This happens only in chrome
What I think
I think the root of all this is that the popstate requests the same type of the pushstate document (js response). What needs to be done is on popstate request the html response.. I just don't know how
More updates:
seeing http://railscasts.com/episodes/246-ajax-history-state it mentions to use
$(window).bind("popstate", function() { $.getScript(location.href); });
this solves the issue but according to understanding jQuery $.getScript() withtout ajax caching it will add timestamps.. which pollutes the url.. turning it off makes it not work again with the same effect..
Anyone knows how to solves this?
Even more Updates
I tracked the trails of the issue all over the interweb and ended with an issue in chrome which points to a rails issue (firefox works fine however) and an issue in rails-ujs concerning not including Vary Header in the responses
Example can be found here
Usually, the Back button in a browser fails to function correctly due to reasons such as redirecting links and conflicting browser extensions. But rarely, you could be dealing with something as serious as a malicious add-on or browser hijacker.
A web page automatically forwarded you to an alternate page Sometimes, when you visit a web page, it automatically directs you to another page. If this occurs and you press the back button, you will immediately be re-forwarded to that same page again.
If you tap and hold the back button in Chrome Android, the option will list out the recently closed history of the website pages that you've visited in the session. This allows you to jump back to any older page without navigating to the subsequent back page.
I am currently playing around with doing
response.headers['Vary'] = 'Accept'
which seems to solve the problem, at first look.
If anyone has the same issue, please check it and let me know
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With