私は AJAX と history.js がまったく初めてです。ナビゲーション項目がクリックされたときに AJAX を使用してコンテンツ領域を変更し、[戻る] ボタンの機能を保持し、ユーザーが mysite.com/page2 などの直接 URL を入力できるようにする基本的なサイトを作成して、それを使用したいと考えています。コンテンツ領域に page2 をロードします。
私は自分が何をしているのか分かりませんが、history.js (ここに見られるように) は私が必要としているもののように見えます. それを試してみると、ここからどこへ行くべきかわかりません。どんな助けでも大歓迎です!
--編集されたjQueryスクリプト
<html>
<head>
<title>test page</title>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.1/jquery.min.js"></script>
<!-- jQuery ScrollTo Plugin -->
<script defer src="http://balupton.github.com/jquery-scrollto/scripts/jquery.scrollto.min.js"></script>
<!-- History.js -->
<script defer src="http://balupton.github.com/history.js/scripts/bundled/html4+html5/jquery.history.js"></script>
<!-- This Gist -->
<script defer src="http://gist.github.com/raw/854622/ajaxify-html5.js"></script>
<script type="text/javascript">
$(window).bind("statechange", function(e) {
var State = window.History.getState();
if (window.console && window.console.log) {
console.log("popstate", State, window.location.href);
}
$("#changehere").text(typeof State.data.changehere !== 'undefined' ? State.data.changehere : State.url);
$('.nav').click(function() {
alert(this);
window.History.pushState({changehere:this}, this + 'title', '?' + this);
})
})
</script>
<style type="text/css">
#one {
height: 300px;
width: 1000px;
background: #a0a0a0;
}
</style>
</head>
<body>
<div id="one">
<a href="xml/first.html" id="first">change1</a>
<a href="xml/second.html" id="second">change2</a>
<a href="xml/third.html" id="third">change3</a>
</div>
<div id="changehere">
start
</div>
</body>