जाँच करने के लिए हालांकि मैं जावास्क्रिप्ट में यह परीक्षण नहीं किया है, मैं अन्य भाषाओं की कोशिश-पकड़ है कि और अधिक एक साधारण अगर से गहन संसाधन है में पता है ...
उपयोग:
if(history.pushState) {
history.pushState({"id":100}, document.title, location.href);
}
ध्यान रखें कि जब आप वापस बटन क्लिक करें, कुछ भी नहीं है वास्तव में जब तक आप को लागू होता है window.onpopstate
। आपको सामग्री को पकड़ने के लिए आवश्यक डेटा में आपको पास करने की आवश्यकता होगी:
if(history.pushState && history.replaceState) {
//push current id, title and url
history.pushState({"id":100}, document.title, location.href);
//push new information
history.pushState({"id":101}, "new title", "/new-url/");
//this executes when you use the back button
window.onpopstate = function(e) {
alert(e.state.id);
//perhaps use an ajax call to update content based on the e.state.id
};
}
स्रोत
2011-03-29 18:40:15
नोट: history.popstate को एक बार कहा जाता है - तुरंत पहले पृष्ठ लोड पर: और यह डिज़ाइन द्वारा है। –