Skip to content

Instantly share code, notes, and snippets.

@wintercn
Last active May 9, 2016 09:06
Show Gist options
  • Save wintercn/9808269 to your computer and use it in GitHub Desktop.
Save wintercn/9808269 to your computer and use it in GitHub Desktop.
一件不开心的事

有一天,我切了个页面,有个按钮点了以后要跳转到另一个页面,于是我把代码这么写:

    window.location = "xxxxxx";

结果那个页面lazyload组件有bug,跳过去一片灰色,沟通了半天没解决,经过反复试验,我发现只要我页面的滚动位置不在顶部就会有问题,于是我想办法绕了过去,代码变成了这样:

    document.body.style.display = "none";
    window.location = "xxxxxx";

代码提测没多久,测试报了个bug,说某些特定手机后退以后页面变白了,大约是客户端的bug后退没刷新页面啊…… 于是我把代码改成了这样:

    document.body.style.display = "none";
    window.location = "xxxxxx";
    setTimeout(function(){
        document.body.style.display = "";
    },100);

以上就是最终代码了,谢谢观赏。

还记得么?我只是想跳转个页面而已…… 艹艹艹艹艹艹艹艹艹艹艹艹艹艹艹

@ethanfu
Copy link

ethanfu commented Mar 27, 2014

github不能赞不开心啊

@lizhug
Copy link

lizhug commented Mar 27, 2014

+1表点赞

@JeffreyZhao
Copy link

LazyLoad组件什么bug会导致window.location跳转灰色?

@myst729
Copy link

myst729 commented Mar 27, 2014

就不能用<a>吗?[挖鼻屎]

@184565673
Copy link

如果跳转页面是动态语言写的,长时间没返回呢?

@yooungt13
Copy link

屁股决定思维,木桶效应。

@cyjake
Copy link

cyjake commented Jun 3, 2014

location.replace 呢?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment