Jqueryアドレスを使用して、次の例に従って簡単なディープリンクページを作成しました:
http://www.asual.com/jquery/address/samples/state/
この例では、HTML5 ブラウザー (私は Chrome 10 を使用しています) に実際に表示されるソースが表示されます。つまり、 http://www.asual.com/jquery/address/samples/state/portfolioは、そのコンテンツがJquery address/Ajax/ を介して挿入されたにもかかわらずPortfolio content.
、 div に表示されます。この例を再構築しましたが、私のページでは、ソースは常に、Ajax が実行される前の最初のページのものです。これは、HTML5 以外のブラウザーと同じ動作です。
私は何を間違っていますか?
ヒントをありがとう、
トーマスcontent
$('.content').html()
編集:
デモコードは次のとおりです。
<script type="text/javascript">
$.address.init(function() {
// Initializes the plugin
$('.nav a').address();
}).change(function(event) {
// Selects the proper navigation link
$('.nav a').each(function() {
if ($(this).attr('href') == ($.address.state() + event.path)) {
$(this).addClass('selected').focus();
} else {
$(this).removeClass('selected');
}
});
// Handles response
var handler = function(data) {
$('.content').html($('.content', data).html()).show();
$.address.title(/>([^<]*)<\/title/.exec(data)[1]);
};
// Loads the page content and inserts it into the content area
$.ajax({
url: $.address.state() + event.path,
error: function(XMLHttpRequest, textStatus, errorThrown) {
handler(XMLHttpRequest.responseText);
},
success: function(data, textStatus, XMLHttpRequest) {
handler(data);
}
});
});
// Hides the tabs during initialization
document.write('<style type="text/css"> .content { display: none; } </style>');
</script>
私のはほとんど同じです。リンクの強調表示を削除し、サイトに一致するように URL を変更し、HTML をロードしているため Ajax 呼び出しを変更しました。それに「何か」があるのだろうか(ドキュメントでは実際には語られていないが、プロジェクトのGitHubで見つけた必要な.htaccessなど)。
これが私のコードです:
$.address.init(function(event) {
$('#blogMenu a').address();
$('#blogBottomMenu a').address();
$('.linkleiste a').address();
}).change(function(event) {
var value = $.address.state().replace(/^\/$/, '') + event.value;
value = value.replace(/^\/blog\//,'');
value = value.replace(/_/,'');
var teile = value.split('/');
var name = '';
var thema = '';
if(teile[0]) name = teile[0];
if(teile[1]) thema = teile[1];
$('#blog').hide();
if(!value.match(/ADFRAME/)) {
$(document).scrollTo('#aufmacher','fast');
$('#blogMenu').load('/snp/blog_menu.snp',{A_NAME:name,ETIKETT:thema,id:id});
$('#blog').load('/blog/article.snp',{A_NAME:name,ETIKETT:thema,id:id},function() {
$('#blog').show();
});
}
else {
$('#blog').fadeIn('fast');
}
});