1

很难找到 Safari 7 的问题,但我有一个奇怪的问题。我正在使用pushstatepopstate修改我编写的 ajax 内容加载器代码的浏览器历史记录。该代码工作正常,除了在除 Safari 7+ 之外popstate的所有浏览器中工作的代码外。在 Safari 6 及更低版本中运行良好。

var popped = ('state' in window.history), initialURL = location.href;
$(window).bind('popstate', function(event){
var initialPop = !popped && location.href == initialURL;
popped = true;
    console.log(event.state);
if ( initialPop ) return;
var state = event.originalEvent.state;
$("#loading").show();
$('#contentwrapper').fadeOut('normal').hide().load(state.url + " #contentwrapper > *").fadeIn('slow');
$("#loading").fadeOut();
});

该脚本在所有浏览器中都能正常工作。在 Safari 7 中,页面加载不正确。正常隐藏的#loadingdiv是可见的,正常可见的#contentwrapperdiv是隐藏的。还收到控制台错误:

TypeError: 'null' is not an object (evaluating 'state.url')
4

0 回答 0