-5

when i want to detect the bottom of my page i use this code which worked fine in a test-file (link below):

$(window).scroll(function() {
    $(window).scrollTop() + $(window).height() == $(document).height(){
       alert(at bottom);
    }
}

But in my final file the exact same code only detects scrolling to the top. can anyone see the mistake or provide a better solution?

Link to test-file: www.warthunder-skins.de/test/

Link to normal file: www.warthunder-skins.de/skins/

  • my bad, totally forgot to add my question. question edited – Max Van den Slampen Jul 13 '15 at 14:24
  • Question not clear... Did you try to use "scrollHeight", prop('scrollTop',...), or other things? what did you try? (((("what do i do wrong?" is not a clear question...)))) – Julo0sS Jul 13 '15 at 14:24
  • One of the first things I notice in the normal file is that you are making calls to `endlessScroll.php` which result in a 404. – Jim Jul 13 '15 at 14:27
  • possible duplicate of [jquery $(window).height() is returning the document height](http://stackoverflow.com/questions/12103208/jquery-window-height-is-returning-the-document-height) – Andreas Jul 13 '15 at 14:30
  • @jim: must be some browsercache? it calls autoload_process.php and not the old endlessScroll.php – Max Van den Slampen Jul 13 '15 at 14:37

2 Answers2

0

To Detect TOP

   $(window).scroll(function() {
        if ($(window).scrollTop() == 0) {
           alert('at the TOP');
        }
    });

To Detect BOTTOM

$(window).scroll(function() {
    if ($(window).scrollTop() + $(window).height() == $(document).height()) {
       alert('at bottom');
    }
});
Ramyz
  • 413
  • 5
  • 11
0

it's some how because of the page header problem

this is your page top 7 lines when i view-source in my browser

<html><head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8"></head><body><br>
<title>Warthunder Skins</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta name="keywords" content="">

Change these line to this !!!

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>Warthunder Skins</title>
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <meta name="keywords" content="">
</head>
<body>

now give a try !!!!

Ramyz
  • 413
  • 5
  • 11
  • thx for your solution. thats somehow strange, cause my source code says in the first line oO i will try it. maybe i should create a new file and copy the code... btw: do not use xhtml anymore ;) – Max Van den Slampen Jul 13 '15 at 15:33