BEGIN;
Most people do not consider the need for the browser to support the forward and backward functions when doing ajax load, because most people do not know how to implement it.
I recently encountered this problem. After a short study, I found that github has already been used as an open-source tool. The main implementation principle is to use the html anchor, that is, <a href = "# xxx">, view https://github.com/balupton/jquery-history/tree/master for details
The main demo code is as follows:
Html
<ul><li><a href="#ttt">ttttttttttttttt</a></li><li><a href="#aaa">aaaaaaaaaaaaaaa</a></li><li><a href="#bbb">bbbbbbbbbbbbbbb</a></li><li><a href="#eee">eeeeeeeeeeeeeee</a></li><li><a href="#mmm">mmmmmmmmmmmmmmm</a></li></ul><div id="showdiv" style="width: 500px; height: 500px; border: 1px groove #e3e7ea;">default content</div>
Js
<Script type = "text/javascript"> $ (function () {// This is a shared location. perform operations using the state parameter $. history. bind (function (state) {$ ('# showdiv '). load ('Action/'{state}'.html ') ;}); // here is a special operation on a link $. history. bind ('bbb ', function (state) {alert ('click the bbb link, which is a special processing location for the bbb link') ;}); </script>
Related questions:
State parameter: the xxx value in the hyperlink tag href = "# xxx.
Execution sequence: perform special operations before performing shared operations.
The detailed source code is as follows:
Http://download.csdn.net/detail/cyzshenzhen/7487091 (csdn) Resources
Git @ OSC source code hosting address: http://git.oschina.net/cyzshenzhen/jquery_history_demo
END;