I have a list with search results that is fetched through ajax (to be precise: the microsoft updatepanel). The problem is that I cannot use the backbutton of any webbrowser to navigate back to previous lists that I fetched through ajax. Do you have an idea?
Thanks
在url中添加一些内容,例如page.html#state1
, page.html#state2
等。这是一种常见的做法
You need to make all the ajax calls update the window.location.hash.
function getAjaxResource(id) {
// some ajax stuff
window.location.hash = 'resource=' + id;
}
Then you need to add a watcher to the hash with javascript's setInterval function.
var hash = window.location.hash;
window.setInterval(function () {
if (window.location.hash != hash) {
hash = window.location.hash;
getAjaxResource(hash.replace('resource=',''));
}
},100);
The hash changes every time the user clicks back/forward and the watcher will pick that change up.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.