【发布时间】:2011-04-19 00:34:24
【问题描述】:
我正在使用 jquery 地址插件,现在我的 URL 类似于 http://localhost:3000/#/users/1/。根据http://code.google.com/web/ajaxcrawling/index.html 的指南,我希望它使用#! 而不仅仅是#。
这是我的 JS:
$('.likable').find('a').click(function(e) {
$.address.value($(this).attr('href').replace(/^#/, '').replace('http://'+document.domain,''));
e.preventDefault();
});
$('.ui-show').find('.close').live('click', function(e) {
history.back();
e.preventDefault();
});
// Setup jQuery Address Listener
$.address.init(function(event) {
if ($.address.baseURL() != 'http://' + document.domain) {
if (location.href.indexOf('#') < 0) {
// URL has no hash value and is a permalink, e.g. /about/
// Change address value to that of permalink
var fullpath = location.href.split('/',4);
$.address.value(fullpath[3] + '/');
}
}
}).change(function(event) {
if (event.value != '/') {
$.get($.address.value(),function(data) {
// Insert new content
});
} else {
// Remove new content
}
});
如何使用#! 而不是#?
【问题讨论】:
标签: ajax jquery hash web-crawler