php - history.js reload page on back button -


i'm new html5 , history.js, still trying grasp concept of history.js. 2 questions here.

  1. is history.js used change url in address bar out page refresh? (like using hash manipulate url)

  2. i've done simple code using history.js (here fiddle)

the url of page 1 http://mysite.com?id=1,2,3

when 1 of button's below pressed, js code hide button , remove id url , using history.js change url in address bar

<input type="button" value="delete id 1" data-remove-id="1" class="remove" />  <input type="button" value="delete id 2" data-remove-id="2" class="remove" />  <input type="button" value="delete id 3" data-remove-id="3" class="remove" /> 

question is, when hit button, url changes correctly, how make unhide hidden button? or how refresh page? or use ajax? best practice?

  1. yes, allows save current state information (if want), , push current url history , load new url url bar. not reload page. assumption doing javascript (an ajax call or other code running) on client corresponds change in url.

  2. your browser's button , history.js not undo javascript code you've done. should use ajax reload page previous url, should readd hidden button. it's slight nuance - pressing button won't unhide button, rather recreate button original code ajax call.

update:

you can bind handler window.onpopstate event.

window.onpopstate = function(event) {   // code... } 

Comments

Popular posts from this blog

java.util.scanner - How to read and add only numbers to array from a text file -

rewrite - Trouble with Wordpress multiple custom querystrings -