php - Backbutton With Ajax loading Content -
this load content page , change url. problem button , forward won't load content agin. change url. how can make them load function?
<a onclick="load_content('p1');" >page1</a> <a onclick="load_content('p2');" >page2</a> function load_content(name) { window.history.pushstate(null, null, "/?page=" + name + ""); var xmlhttp; if (window.xmlhttprequest) {// code ie7+, firefox, chrome, opera, safari xmlhttp=new xmlhttprequest(); } else {// code ie6, ie5 xmlhttp=new activexobject("microsoft.xmlhttp"); } xmlhttp.onreadystatechange=function() { if (xmlhttp.readystate==4 && xmlhttp.status==200) { document.getelementbyid("response").innerhtml=xmlhttp.responsetext; } } xmlhttp.open("get","load_content.php?name=" + name + "",true); xmlhttp.send(); }
in history.pushstate
, save relevant data dynamic , listen popstate
event , replace elements ajax.
Comments
Post a Comment