这只是一些 js(jQuery)
<script type="text/javascript">
var current_page = '';
$("a").live("click", function(){
return change_hash(this,1);
});
function change_hash(el,type) {
if(type==1) {
var link = $(el).attr("href");
}
else
{
var link = el;
}
var link_ar = link.split('/#!');
if(link_ar[1]!=undefined) {
if((link_ar[1].length>3)&&(link_ar[1].substr(0,1)=='/')) {
window.location.hash = '#!'+link_ar[1];
return false;
}
else
{
return true;
}
}
else
{
return true;
}
return false;
}
$(function(){
$(window).hashchange( function(){
address = location.hash.replace("#!","");
var skip=false;
if((address.substr(0,1)=='/')&&(address!=current_page)) {
$("#content").html('<div class="content-box"><div class="ajax-loading">carregando...</div></div>');
$("html, body").animate({ scrollTop: 0 }, "slow");
if (address.indexOf(".php") == -1) {
var newaddress = address.replace(/[^a-zA-Z0-9_\.]+/g,"");
if('/'+newaddress!=address) { change_hash('/#!/'+newaddress,2);skip=true; }
address='/PerfilDetalhe.php?user='+newaddress;
}
if(skip==false) {
$.get('http://www.suamusica.com.br'+address, function(htmldata) {
$("#content").html(htmldata);
document.title = $('#metaTitle').val();
$('meta[name=description]').attr('content', $('#metaDescr').val());
$('meta[name=keywords]').attr('content', $('#metaKeywords').val());
$('meta[property="og\\:description"]').attr('content', $('#metaDescr').val());
$('meta[property=og\\:title]').attr('content', $('#metaTitle').val());
$('meta[property=og\\:url]').attr('content', $('#metaURL').val());
$('meta[property=og\\:image]').attr('content', $('#metaImage').val());
$('meta[property=og\\:type]').attr('content', $('#metaType').val());
$('meta[name=DC\\.title]').attr('content', $('#metaTitle').val());
$('meta[name=DC\\.description]').attr('content', $('#metaDescr').val());
$('meta[name=DC\\.subject]').attr('content', $('#metaKeywords').val());
}).fail(function() { $("#content").html('<div class="content-box error-box"><h1>Ooops!</h1><p>A página acessada não existe ou não foi encontrada.</p></div>'); });
current_page = address;
}
$.get('http://www.suamusica.com.br/msg_check.php', function(resp) {
if(resp==1) {
$('#msg-notify').show();
}
else $('#msg-notify').hide();
})
$('.tipsy-s').remove();
}
});
var loc_h_n = window.location.hash.replace("#", "").replace("!", "").replace(".do", ".php")
if(window.location.hash!='#!'+loc_h_n&&window.location.hash!='') {
window.location.hash = '#!'+loc_h_n;
}
$(window).hashchange();
});
</script>
如您所见,他在点击时返回 false 并根据主题标签值采取行动