检测“body”内向下滚动

Kim*_*Kim 7 jquery scroll

我在 Facebook iframe 中有一个应用程序,需要知道用户何时在体内向下滚动。我现在拥有的这段代码只能检测整个窗口。但我无法让它发挥作用,所以它在体内燃烧。

我有什么想法可以修改这个吗?

//lastAddedLiveFunc();
$(window).scroll(function(){

    var wintop = $(window).scrollTop(), docheight = $(document).height(), winheight = $(window).height();
    var  scrolltrigger = 0.95;

    if  ((wintop/(docheight-winheight)) > scrolltrigger) {
     //console.log('scroll bottom');
     lastAddedLiveFunc();
    }
});
Run Code Online (Sandbox Code Playgroud)

imb*_*ile 5

尝试这个:

$('body').on('scroll', function (e){
    if ($('#selector').has($(e.target)).length){                       
     //do what you want here
    }
});
Run Code Online (Sandbox Code Playgroud)

我主要将其用于触摸设备,但尝试一下并没有什么坏处:)