Estoy tratando de usar window.pageYOffset & window.scrollMaxY para calcular el progreso de la página actual. Este enfoque funciona bajo FF3.5 pero bajo webkit window.scrollMaxY no está definido.Alternativas a window.scrollMaxY?
9
A
Respuesta
2
Tengo distancia con document.body.scrollHeight
modo que
document.body.scrollHeight = window.pageYOffset + screen height in pixels
al final de la página (en Android).
14
Alternativa a window.scrollMaxY
:
document.documentElement.scrollHeight - document.documentElement.clientHeight
da mismo resultado que window.scrollMaxY
con ie7, ie8, FF3.5, Safari 4, Opera 10, Google Chrome 3 bajo XHTML DOCTYPE 1.0 de Transición.
3
y dos años después ...
function getScrollMaxY(){
var innerh;
if (window.innerHeight){
innerh = window.innerHeight;
}else{
innerh = document.body.clientHeight;
}
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
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
Cuestiones relacionadas
- 1. Alternativas a Inflector.Net
- 2. Alternativas a DWR (www.directwebremoting.org)
- 3. Alternativas a Applescript?
- 4. Alternativas a TOAD (Linux)
- 5. Alternativas a HtmlAgilityPack?
- 6. Alternativas a ppl
- 7. Alternativas a GNU diff?
- 8. Alternativas a corrutinas
- 9. hay alternativas a yUML
- 10. Alternativas a hibernar
- 11. Alternativas ORM a ActiveRecord
- 12. Alternativas a gettext?
- 13. Alternativas a System.exit (1)
- 14. Alternativas a popen/pclose?
- 15. Alternativas a YQL
- 16. Alternativas a @VisibleForTesting
- 17. Alternativas a xargs -l
- 18. Alternativas a WCF
- 19. Alternativas a Yahoo Pipes
- 20. Alternativas a stats :: reshape
- 21. Alternativas a CKAN
- 22. Alternativas a ERB
- 23. Alternativas a JUnit
- 24. Alternativas a expresiones regulares
- 25. Alternativas a Neptuno
- 26. alternativas a jpivot?
- 27. Alternativas a vtable
- 28. C# Alternativas a Tika
- 29. Alternativas a Thread.Sleep()
- 30. Alternativas a Bootstrap for Rails
Gracias buen señor. Me encantaría saber si hay algún inconveniente para usar este método. ¡Lo probé en Chrome/Firefox y funciona! – swajak
Tratando de implementarlo contra 'window.scrollY' Observé que al menos en cromo,' window.scrollY' es un flotador de alta precisión, mientras que 'scrollHeight' y' clientHeight' son enteros, por lo que tuve que 'Math.round() ' – Kaiido