This question was already asked here a long time ago:
Detect jquery event trigger by user or call by code
But it has never been answered conclusively (or m
I would suggest First of all create a javascript function
// Attaching scroll event when document/window is loaded
function OnFirstLoad() {
if (document.attachEvent) {
document.attachEvent('onscroll', scrollEvent);
} else if (document.addEventListener) {
document.addEventListener('scroll', scrollEvent, false);
}
}
then, use either
window.onload = OnFirstLoad;
Or
$(document).ready(function () {
OnFirstLoad();
});
In This scroll event is a function
function scrollEvent(e) {
var body = document.body,
html = document.documentElement;
var docHeight = Math.max(body.scrollHeight, body.offsetHeight,
html.clientHeight, html.scrollHeight, html.offsetHeight);
var currentScroll = (document.documentElement && document.documentElement.scrollTop) || document.body.scrollTop;
// implement your logic according to requirement
}