Problem with catching javascript page size

Asked

Viewed 58 times

0

My script works normal, when it arrives at the end of the main page it calls another in which it will return a text, adding a text at the end of the main page. The problem is q, after adding the texts, the page grows, then the script n works more. It’s as if it n recalculates the size.

<script type="text/javascript"
  src="http://ajax.googleapis.com/ajax/libs/jquery/1.4/jquery.min.js"></script>
<script type="text/javascript">
$(document).ready(function(){
  var posicaoAtual = $(window).scrollTop();
  var documentSize = $(document).height();
  var sizeWindow = $(window).height();

  $(window).scroll(function () {
    posicaoAtual = $(window).scrollTop()+50;
  if ( posicaoAtual >= (documentSize - sizeWindow ) ) {
      //alert ("Final do documento ->" + posicaoAtual);
        $.ajax({
           url:'particoes/showmoreposts.php', //Página PHP que seleciona postagens
           type:'POST', // método post, GET ...
           data: 'limit=10&offset=0', //seus paramêtros
           success: function(data){ // sucesso de retorno executar função
             $('#meio').append(data); // adiciona o resultado na div #conteudo
           } // fim success
        }); // fim ajax
    }
  });

  $(window).resize(function() {
    posicaoAtual = $(window).scrollTop();
    documentSize = $(document).height();
    sizeWindow = $(window).height();
  });


});
</script>


na pagina showmoreposts:
<?php
echo "<span>aaaaaaaaaaaaaaaasasasas<br><br>";
?>`

1 answer

-3

document.documentElement.clientHeight

Browser other questions tagged

You are not signed in. Login or sign up in order to post.