How do I get the browser to support jquery ajax load forward and backward

  • 2020-03-30 03:18:21
  • OfStack

When doing ajax load, most people don't think about the need for the browser to support forward and backward functions, because most people don't know it can be done.

Recently, after a little research, I found that github already has an existing open source tool to use. A href = "# XXX" >

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 the Shared location, and we're doing it with the state parameter
$.History.bind(function(state){ 
$('#showdiv').load('action/'+state+'.html'); 
}); 
//This is a special operation on a link
$.History.bind('bbb',function(state){ 
alert(' Click on the  bbb  Link, that's right  bbb  Links to special processing locations '); 
}); 
}); 
</script> 

Related questions:

State parameter: the value of XXX in the hyperlink tag href="# XXX ".

Execution sequence: special operations followed by common operations.

Related articles: