First of all please don't mark it as duplicate question because I have seen all the questions regarding this topic and tried all the solutions but none of them helped me.Here is my JSP page:
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>JSP Page</title>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<script>
$(window).scroll(function () {
if ($(window).scrollTop() >= ($(document).height()-250) - ($(window).height())) {
more_options();
}
});
function more_options()
{
alert("hii");
}
</script>
</head>
<body>
<h1>Hello</h1>
<h1>Hello</h1>
<h1>Hello</h1>
<h1>Hello</h1>
<h1>Hello</h1>
<h1>Hello</h1>
<h1>Hello</h1>
<h1>Hello</h1>
<h1>Hello</h1>
<h1>Hello</h1>
<h1>Hello</h1>
<h1>Hello</h1>
<h1>Hello</h1>
</body>
</html>
I was trying to make facebook like scroll for showing more features as soon as user scrolls to half of the page.The above function
$(window).scroll(function () {
if ($(window).scrollTop() >= ($(document).height()-250) - ($(window).height())) {
more_options();
is working well in Chrome but when i run this page in Mozilla Firefox it repeatedly calls the more_options function and shows irrelevant output.Actually the more_options function show here is demo with alert int it but actually I am using AJAX in that function and fetching more results from database.Chrome Shows the actual result but Mozilla shows unexpected result and repeat the entries come from AJAX call.
Here is Jsfiddle.