jQuery页面过渡和浏览器历史记录 [英] jQuery page transition and browser history

查看:95
本文介绍了jQuery页面过渡和浏览器历史记录的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用jQuery,以便在我的html页面上产生淡入效果,效果很好。但是,当我点击浏览器中的后退按钮时,我转到了正确的网址,但页面空白。这是浏览器缓存的东西吗?我是jQuery的新手,我不确定如何解决这个问题。
这是网站: http://www.e-preview。 be / huyzewaterloos / nl / index.html

I'm working with jQuery to have a fade-in effect on my html page, which works just fine. However, when I hit the back-button in my browser, I go to the right url but get a blank page. Is this a browser-caching thing? I'm relatively new to jQuery and I'm not really sure how to solve this. This is the site: http://www.e-preview.be/huyzewaterloos/nl/index.html

我正在使用的代码是:

//page transition
    $("body").css("display", "none");
    $("body").fadeIn(1500);
  $("a.transition").click(function(event){
   event.preventDefault();
   linkLocation = this.href;
   $("body").fadeOut(500, redirectPage);
  });

 function redirectPage() {
  window.location = linkLocation;
 }


推荐答案

这是因为您的页面位于 bfcache(请参阅​​ Firefox文章)。要禁用bfcache,您只需添加onunload属性即可:

It's because you page is in "bfcache" (see a Firefox article). For disable bfcache, you can just add an onunload attribut:

<body onunload="">

来源: Ajax,后退按钮和DOM更新单击后退按钮时是否存在跨浏览器的onload事件?

这篇关于jQuery页面过渡和浏览器历史记录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆