onclick函数外部页面加载div中的ajax函数,其历史记录返回浏览器
<script type="text/javascript">
jQuery(document).ready(function () {
jQuery.history.init(pageload);
jQuery('a[rel=ajax]').click(function () {
var hash = this.href;
hash = hash.replace(/^.*#/, '');
jQuery.history.load(hash);
getPage();
return false;
});
});
function pageload(hash) {
//if(!hash){
// document.location.hash='test4.html';
//}
if (hash) getPage();
}
function getPage() {
var data = 'page=' + encodeURIComponent(document.location.hash);
jQuery.ajax({
url: document.location.hash.replace(/^.*#/, ''),
type: "GET",
data: data,
cache: false,
success: function (html) {
jQuery('#content').html(html);
jQuery('a[rel=ajax]').removeClass('selected');
jQuery('a[href=' + window.location.hash + ']').addClass('selected');
}
});
}
</script>
如何更改onClick功能
<a href="#test1.html" rel="ajax">1</a>