jon*_*br1 6 javascript location google-chrome
我正在网上做一些窥探,并发现window.location.hash = "etc"是一种广泛采用的方法来更新浏览器的位置而无需重新加载/刷新页面.我已经应用了这个例子我已经熟了:http://dl.dropbox.com/u/1595444/locationExample/index.html
适用于Safari,但......
我注意到的是,Chrome 10+在更改后hash:
有没有人遇到过这个问题?知道修复吗?
这里最有可能发生两件事:
pushState,但散列更改位于相同的代码路径上),favicon和停止/刷新按钮会闪烁.两者的解决方法是推迟更新哈希,直到用户完成滚动(您仍然可以立即更新当前项下显示的白条).您可以通过以下方式执行此操作:
var scrollTimeout;
window.onscroll = function() {
  // update current item display here
  if (scrollTimeout)
    clearTimeout(scrollTimeout);
  scrollTimeout = setTimeout(function() {
    scrolTimeout = undefined;
     // update hash here
  }, 100);
};
Run Code Online (Sandbox Code Playgroud)
因为看起来你正在使用jQuery,所以有一些可能有用的去抖动插件.
|   归档时间:  |  
           
  |  
        
|   查看次数:  |  
           7288 次  |  
        
|   最近记录:  |