admin管理员组文章数量:1410730
My code can detect browser window bottom like below and then run last_msg_funtion();
:
$(window).scroll(function(){
if ($(window).scrollTop() == $(document).height() - $(window).height()){
last_msg_funtion();
}
});
My problem is user need to scroll down until bottom(footer) then last_msg_funtion();
will run but i want adjust the detection maybe around 30% from bottom
See image below :
My Site : Click Here
Full Code : Click Here
My code can detect browser window bottom like below and then run last_msg_funtion();
:
$(window).scroll(function(){
if ($(window).scrollTop() == $(document).height() - $(window).height()){
last_msg_funtion();
}
});
My problem is user need to scroll down until bottom(footer) then last_msg_funtion();
will run but i want adjust the detection maybe around 30% from bottom
See image below :
My Site : Click Here
Full Code : Click Here
Share Improve this question asked Jan 18, 2013 at 9:13 ruslyrusly 1,5226 gold badges29 silver badges62 bronze badges2 Answers
Reset to default 6Try this:
$(window).scroll(function(){
if ($(window).scrollTop() == ($(document).height() * 0.7) - $(window).height()){
last_msg_funtion();
}
});
Note the * 0.7
will mean that the function will fire when the scroll is 70% of the way down the page - ie. 30% from the bottom.
Try these:
$(window).scroll(function(){
if ($(window).scrollTop() >= ($(document).height() * 0.7) - $(window).height()){
last_msg_funtion();
}
});
you have to use >=
in if condition.
If you use ==
then last_msg_funtion() will call only when scroll is 70% on way.
If you use >=
then last_msg_funtion() will call only when scroll is greater than 70% on way.
本文标签: javascriptDetect 30 from browser window bottom using scrollTop()Stack Overflow
版权声明:本文标题:javascript - Detect 30% from browser window bottom using scrollTop() - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1745038304a2638922.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论