我想从另一个URL使用pushstate/html5加载内容...我想加载的内容有一个大的背景图片,需要时间加载...加载图片/内容后从外部URL的内容
所以,当动画快满形象似乎要拿出和幻灯片中,但随后又形象重新加载...
我尝试使用
image preloader/
$(document).ready()
他们都打破了脚本,不能完全似乎弄清楚如何在这里加入它
function goTo(href) {
var left = $(window).width();
$('#id').css("left", left);
$.ajax({
url: href,
success: function (data) {
var content = $(data).find('#id').html();
// Windows Load Function
$(window).load(function() {
$("#id").html(content).animate({
left: '0',
}, 'fast');
var title = $('#id').find('h1').text();
$('head').find('title').text(title);
});
}
});
}
// check for support before we move ahead
if (typeof history.pushState !== "undefined") {
var historyCount = 0;
// On click of link Load content and animate
$('.access a').live('click', function() {
var href = $(this).attr('href');
goTo(href);
history.pushState(null, null, href);
return false;
});
window.onpopstate = function() {
if (historyCount) {
goTo(document.location);
}
historyCount = historyCount + 1;
};
}
什么是'图像预加载/行'应该是?我怀疑,如果没有别的东西,就会把这些作品搞砸了。不要以为JavaScript会接受。 – KRyan 2012-08-01 20:04:18
在这种情况下,“href”是什么?它不是外在的吗? – 2012-08-01 20:06:43
抱歉,我的意思是说我试过preloader方法...我不知道我在哪里把preloader在 – MonteCristo 2012-08-01 20:09:05