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 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65
| <html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>history plugin</title>
<script type="text/javascript" src="jquery-1.3.2.min.js"></script>
<script type="text/javascript" src="jquery.history.js"></script>
<script type="text/javascript">
// PageLoad function
// This function is called when:
// 1. after calling $.historyInit();
// 2. after calling $.historyLoad();
// 3. after pushing "Go Back" button of a browser
function pageload(hash) {
// hash doesn't contain the first # character.
if(hash) {
// restore ajax loaded state
$("#load").load(hash + ".html");
} else {
// start page
$("#load").empty();
}
}
$(document).ready(function(){
// Initialize history plugin.
// The callback is called at once by present location.hash.
$.historyInit(pageload);
// set onlick event for buttons
$("a[rel='history']").click(function(){
//
var hash = this.href;
hash = hash.replace(/^.*#/, '');
// moves to a new page.
// pageload is called at once.
$.historyLoad(hash);
return false;
});
});
</script>
</head>
<body>
This plugin helps you make your Ajax-driven page available for "Go Back" button and "bookmark" of browser.<br>
source: <a href="jquery.history.js">jquery.history.js</a> (Last Update: 2009/03/20)<br>
<br>
Work on IE8, FireFox 4.0, Opera9, Safari 4.0, Chrome 1.0. <br>
<br>
Safari support & bug fix on IE6 was offered by Lincoln Cooper. Thanks.
<br>
Fix IE6 problem was offered by Anton. Thanks.
<br>
Support IE8 was offered by Yohann MARTEL. Thanks.
<hr>
Ajax load<br>
<a href="#1" rel="history">load 1</a><br>
<a href="#2" rel="history">load 2</a><br>
<a href="#3" rel="history">load 3</a><br>
<hr>
Loaded html:<br>
<div id="load"></div>
<hr>
<a href="/">mikage's page. (Japanese)</a>
</body>
</html> |