Ir para conteúdo

Arquivado

Este tópico foi arquivado e está fechado para novas respostas.

Elizandro Tavares

DOCTYPE - Script não roda.

Recommended Posts

Boa Tarde

 

Estou usando este script http://www.infotuts.com/ajax-infinite-scroll-using-jquery-php-mysql/

para fazer auto load sempre que chegamos ao final da página, porém quando declaro o tipo

 

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

 

ele para de funcionar, ou seja não carrega os proximos registros, ai removo a declação funciona de boa.

 

O que pode ser?

 

Obrigado.

 

 

Compartilhar este post


Link para o post
Compartilhar em outros sites

O que aparece no console de erros ?

 

Ctrl + Shift + J no Firefox ou Chrome.

Compartilhar este post


Link para o post
Compartilhar em outros sites

Console não acusa nenhum erro.

 

Coloco:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR...l1-strict.dtd">

não funciona.

 

Removo, ele faz o scroll normal.

Compartilhar este post


Link para o post
Compartilhar em outros sites

Poste um link para o teu site para verificarmos.

Compartilhar este post


Link para o post
Compartilhar em outros sites

Compartilhar este post


Link para o post
Compartilhar em outros sites

O problema é nesse if:

 

if ((($(window).scrollTop()+document.body.clientHeight)==$(window).height()) && isload=='true'){
Pelo visto o código foi desenvolvido com bug, e não corrigiram.

Compartilhar este post


Link para o post
Compartilhar em outros sites

Troque:

 

if ((($(window).scrollTop()+document.body.clientHeight)==$(window).height()) && isload=='true'){
por

console.log(
  '$(window).scrollTop(): ', $(window).scrollTop(),
  'document.body.clientHeight: ', document.body.clientHeight,
  '$(window).height(): ', $(window).height()
);
if ((($(window).scrollTop()+document.body.clientHeight)==$(window).height()) && isload=='true'){
apenas para debug e para verificarmos quais os valores corretos a serem colocados.

 

Acompanhe no Ctrl + Shift + J, e faça as contas.

Compartilhar este post


Link para o post
Compartilhar em outros sites

COM Declaração de Tipo: não funciona

$(window).scrollTop(): 100 document.body.clientHeight: 770 $(window).height(): 401
$(window).scrollTop(): 200 document.body.clientHeight: 770 $(window).height(): 401
$(window).scrollTop(): 300 document.body.clientHeight: 770 $(window).height(): 401
$(window).scrollTop(): 400 document.body.clientHeight: 770 $(window).height(): 401
$(window).scrollTop(): 479 document.body.clientHeight: 770 $(window).height(): 401
SEM Declaração de tipo: Funcona
$(window).scrollTop(): 100 document.body.clientHeight: 401 $(window).height(): 880
$(window).scrollTop(): 200 document.body.clientHeight: 401 $(window).height(): 880
$(window).scrollTop(): 300 document.body.clientHeight: 401 $(window).height(): 880
$(window).scrollTop(): 400 document.body.clientHeight: 401 $(window).height(): 880
$(window).scrollTop(): 479 document.body.clientHeight: 401 $(window).height(): 880

Compartilhar este post


Link para o post
Compartilhar em outros sites

Viu como os valores são inconsistentes ?

 

"Não funciona", pq quem projetou o script fez errado.

 

Deixa só assim:

 

if (($(window).scrollTop() > document.body.clientHeight) && isload=='true'){

Compartilhar este post


Link para o post
Compartilhar em outros sites

SEM Declarar:

Esse é o resultado do scrol completo, porém com o a linha que me passasse ele só ativa se a janela não estiver com o height máximo, ou seja tenho que reduzir o height da janela, abrir o console por exemplo ou simplesmente reduzir a altura do navegador.

 

$(window).scrollTop(): 100 document.body.clientHeight: 763 $(window).height(): 880
$(window).scrollTop(): 117 document.body.clientHeight: 763 $(window).height(): 880
$(window).scrollTop(): 17 document.body.clientHeight: 763 $(window).height(): 880
$(window).scrollTop(): 0 document.body.clientHeight: 763 $(window).height(): 880
$(window).scrollTop(): 100 document.body.clientHeight: 401 $(window).height(): 880
$(window).scrollTop(): 200 document.body.clientHeight: 401 $(window).height(): 880
$(window).scrollTop(): 300 document.body.clientHeight: 401 $(window).height(): 880
$(window).scrollTop(): 400 document.body.clientHeight: 401 $(window).height(): 880
$(window).scrollTop(): 479 document.body.clientHeight: 401 $(window).height(): 880
$(window).scrollTop(): 579 document.body.clientHeight: 401 $(window).height(): 1504
$(window).scrollTop(): 679 document.body.clientHeight: 401 $(window).height(): 1504
$(window).scrollTop(): 779 document.body.clientHeight: 401 $(window).height(): 1504
$(window).scrollTop(): 879 document.body.clientHeight: 401 $(window).height(): 1504
$(window).scrollTop(): 979 document.body.clientHeight: 401 $(window).height(): 1544
$(window).scrollTop(): 1079 document.body.clientHeight: 401 $(window).height(): 1544
COM Declaração:
$(window).scrollTop(): 100 document.body.clientHeight: 770 $(window).height(): 401
$(window).scrollTop(): 200 document.body.clientHeight: 770 $(window).height(): 401
$(window).scrollTop(): 300 document.body.clientHeight: 770 $(window).height(): 401
$(window).scrollTop(): 400 document.body.clientHeight: 770 $(window).height(): 401
$(window).scrollTop(): 479 document.body.clientHeight: 770 $(window).height(): 401

Compartilhar este post


Link para o post
Compartilhar em outros sites

Ou vc estuda o script e faz a correção.

Compartilhar este post


Link para o post
Compartilhar em outros sites

×

Informação importante

Ao usar o fórum, você concorda com nossos Termos e condições.