我有一个问题。
I have a page that stores the current scrollTop() position in session when unloading. My goal is that when I come back to this page, the page scrolls until the last scrollTop position I had on it.
我的联合材料法典简单:
console.log( => +parseInt(scrollto)+ +parseInt($(window).scrollTop()));
$(window).scrollTop(scrollto);
console.log( => +parseInt(scrollto)+ +parseInt($(window).scrollTop()));
摘录:
=> 2500 0
=> 2500 2500
奥基,我一页在最后的张贴上。
The issue comes with big values of scrollto variable. This is what I ve got in console :
=> 12352 0
=> 12352 7683
我拿不出为什么没有按要求的职位分配。
我甚至试图这样做:
var max_times= 10;
for(var i=0;i<max_times;i++){
console.log( => +parseInt(scrollto)+ +parseInt($(window).scrollTop()));
if (parseInt(scrollto) > parseInt($(window).scrollTop()))
$(window).scrollTop(scrollto);
}
结果:
=> 13450 0
=> 13450 7985
=> 13450 7985
=> 13450 7985
...
=> 13450 7985
其他信息:
- I have the same result on Chrome and Safari.
- The page I m talking about contains a lot of images so it takes some time to be fully loaded.
我确实希望得到任何帮助。
谢谢。