javascript - Force refresh/reload when user navigates Back and forward again -
i want know how can ensure page reload/refresh when user presses button , presses forward again.? please help!
you can use cookie set "back button pressed" flag.
eg. jquery + jquery cookie plugin
$(document).ready(function($) { if ($.cookie("reload") === *your-page-id*) { $.removecookie("reload"); location.reload(); } else if (window.history && window.history.pushstate) { window.history.pushstate("forward", null, "./#forward"); $(window).on("popstate", function() { $.cookie("reload", *your-page-id*); // set cookie page id }); } });
since popstate
not supported older browsers should use history.js
Comments
Post a Comment