我有一个使用ajax加载内容的网站。现在我想要实现jQuery地址插件以获得更好的用户体验和SEO抓取。
使用这行代码
需要使用
文档非常简陋:http://www.asual.com/jquery/address/docs/ 以下是我的代码:
基本实现如下所示:
任何帮助都将不胜感激。谢谢。
使用这行代码
$.address.value($(this).attr('href'));
,地址更改功能有效,但如何实现历史支持、抓取等功能呢?需要使用
$.address.change(function(event){...});
来完成一些操作,但是具体如何操作呢?我已经尝试将$("#content").load(toLoad,'',showNewContent)
放入其中,并尝试了其他上千种方法,但都没有结果。文档非常简陋:http://www.asual.com/jquery/address/docs/ 以下是我的代码:
$('a:not([href^=http])').click(function() {
var toLoad = $(this).attr('href') + " #ajaxedContent";
$("#content").fadeOut(600,loadContent);
$("#load").remove();
$('#logo').append('<div id="load"></div>');
$("#load").fadeIn(100);
$.address.value($(this).attr('href'));
function loadContent() {
$("#content").load(toLoad,'',showNewContent)
}
function showNewContent() {
// Capture the final dimensions of the content element and animate, finally fade content in
$("#limit").animate({height: $("#content").height()},600,'easeInOutQuad',function() {
$("#content").fadeIn(600,hideLoader);
callback();
});
}
function hideLoader() {
$("#load").fadeOut(300);
}
return false;
});
基本实现如下所示:
$.address.change(function(event) {
// do something depending on the event.value property, e.g.
// $('#content').load(event.value + '.xml');
});
$('a').click(function() {
$.address.value($(this).attr('href'));
});
任何帮助都将不胜感激。谢谢。