javascript - Back button isn't reloading page on ajax site -
i have added ajax client's site enable simple animation of page transitions. if navigate homepage (with js enabled) @ firedogcreative.com , navigate edit page, , 1 of work pages; end history this:
firedogcreative.com --> firedogcreative.com/#edit --> firedogcreative.com/#example1 ajax takes care of loading content of each of pages in, updates hash in url bar in each case, , works planned.
when user clicks button, though, i'm not sure understand happening. if @ #example1 , hit browser's button, url bar updates firedogcreative.com/#edit, page content doesn't change. if user reloads page, though, correctly reloads #edit.
i tried adding this, thought cause pages not cache , each button call reload page, didn't seem have effect:
window.onbeforeunload = function () { // stuff do before window unloaded here. }; if worked, passable solution. page ever reload when user uses forward/back buttons, fine.
so question is, going on button? shouldn't onbeforeunload causing backbutton reload based on stored url?
so question is, going on button?
it going previous url.
since changing fragment identifier track application state hack, nothing else happens.
shouldn't onbeforeunload causing backbutton reload based on stored url?
no. navigating within same document, isn't being unloaded.
you need monitor hashchange event , change application state own js.
alternatively, switch using pushstate , watch popstate event.
Comments
Post a Comment