您可以使用 jquery 的历史插件 ( http://www.mikage.to/jquery/jquery_history.html ) 来处理向后和向前导航并通过 ajax 加载页面,就像您所说的那样。
像这样的东西应该可以工作(未经测试):
第1页.htm:
<html>
<head><title>Page 1</title></head>
<body>
<div id="content">
<a href="/page2.htm">Load Page 2</a>
</div>
<div id="chat"></div>
</body>
<script>
$(function(){
function loadPage(hash){
if($.browser.msie) {
hash = encodeURIComponent(hash);
}
$.ajax({
"url":hash,
"success":function(response){
var newPage = $(response);
document.title=newPage.find("title").html();
$("#content").html(newPage.find("#content").html());
}
});
return false;
}
$.historyInit(loadPage);
$("a").live("click",function(){
$.historyload(this.href);
});
});
</script>
</html>
Page2.htm:
<html>
<head><title>Page 2</title></head>
<body>
<div id="content">
<a href="/page1.htm">Load Page 1</a>
</div>
<div id="chat"></div>
</body>
<script>
$(function(){
function loadPage(hash){
if($.browser.msie) {
hash = encodeURIComponent(hash);
}
$.ajax({
"url":hash,
"success":function(response){
// this is just an example and not too efficient.
var newPage = $(response);
document.title=newPage.find("title").html();
$("#content").html(newPage.find("#content").html());
}
});
return false;
}
$.historyInit(loadPage);
$("a").live("click",function(){
$.historyload(this.href);
});
});
</script>
</html>
如果您想将工作外包给我,我很乐意提供帮助。:o)