script document ready function click function var url this attr href a

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
<script>
$(document).ready(function() {
$('a').click(function() {
var url = $(this).attr('href');
$.ajax({
url: url + '?ajax=1',
success: function(data){
$('#content').html(data);
}
});
if(url != window.location){
window.history.pushState(null, null, url);
}
return false;
});
$(window).bind('popstate', function() {
$.ajax({
url: location.pathname + '?ajax=1',
success: function(data) {
$('#content').html(data);
}
});
});
});
</script>