我建立使用jQuery地址而下面這個實例一個簡單的深層鏈接頁:在這個例子中
http://www.asual.com/jquery/address/samples/state/地址州混亂
現在,HTML5瀏覽器(我使用的是Chrome 10),顯示實際顯示的源。即http://www.asual.com/jquery/address/samples/state/portfolio在content
div中顯示Portfolio content.
,即使該內容是通過Jquery地址/ Ajax/$('.content').html()
插入的。我重建了這個例子,但在我的頁面上,源代碼始終是初始頁面之一,在執行任何Ajax之前。這與在非HTML5瀏覽器中的行爲相同。
我在做什麼錯?
感謝提示,
托馬斯
編輯:
這裏的演示代碼:
<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>
礦的幾乎相同。我刪除了鏈接突出顯示,將網址更改爲與我的網站相匹配,並在加載html後更改了Ajax調用。我想知道是否還有「更多的東西」(比如文檔沒有提到的必要的.htaccess,但是我在項目的GitHub中找到的)。
這裏是我的代碼:
$.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');
}
});
如果您沒有向我們展示您在做什麼,我們應該如何知道您做錯了什麼? – kapa
你有一點。我粘貼了演示來源 – thomas
Uhoh WALL的文字.. –