12
votes

Alternatives à Window.scrollmaxy?

J'essaie d'utiliser fenêtre.PageYoffset & fenêtre.scrollmaxy Pour calculer la page actuelle progression. Cette approche fonctionne sous FF3.5 mais sous WebKit window.scrollmaxy est indéfinie.


0 commentaires

4 Réponses :


2
votes

Je suis sorti avec document.body.scrollheight de sorte que xxx

à la fin de la page (sur Android). < / p>


0 commentaires

16
votes

alternative à fenêtre.scrollmaxy : xxx

donne le même résultat que fenêtre.scrollmaxy avec IE7, IE8, FF3.5, Safari 4, Opéra 10, Google Chrome 3 Sous Doctype XHTML 1.0 Transitional.


2 commentaires

Merci bon monsieur. J'aimerais savoir s'il y a des inconvénients pour utiliser cette méthode. Je viens de le tester à Chrome / Firefox et ça marche!


Essayer de le mettre en œuvre contre window.scrolly J'ai remarqué que dans le chrome au moins, fenêtre.scrolly est un flotteur de haute précision, tandis que Scrollheight et ClientHeight sont des entiers, donc j'ai dû math.round () il



3
votes

Deux ans plus tard ...

function getScrollMaxY(){"use strict";
    var innerh = window.innerHeight || ebody.clientHeight, yWithScroll = 0;

    if (window.innerHeight && window.scrollMaxY){
        // Firefox 
        yWithScroll = window.innerHeight + window.scrollMaxY; 
    } else if (document.body.scrollHeight > document.body.offsetHeight){ 
        // all but Explorer Mac 
        yWithScroll = document.body.scrollHeight; 
    } else { 
        // works in Explorer 6 Strict, Mozilla (not FF) and Safari 
        yWithScroll = document.body.offsetHeight; 
    } 
    return yWithScroll-innerh; 
}


0 commentaires

0
votes
 x = document.body.clientHeight;
 console.log(x ,"Cline HEight");     

 xx = window.innerHeight;
 console.log(xx, "Inner Height");

 xxx = document.body.scrollHeight
 console.log(xxx, "scrollHeight");

 xxxx = window.scrollMaxY; 
 console.log(xxxx, "scrollMaxY for IE");


 xxxxx = document.body.offsetHeight;
 console.log(xxxxx, "offsetHeight");

 xxxxxx= document.body.scrollTop;
 console.log(xxxxxx, "scrollTop");strong text

0 commentaires