Próbuję użyć window.pageYOffset & window.scrollMaxY do obliczenia postępu bieżącej strony. To podejście działa w trybie FF3.5, ale pod Windowkit window.scrollMaxY jest niezdefiniowany.Alternatywy dla window.scrollMaxY?
9
A
Odpowiedz
2
Mam sucho document.body.scrollHeight
tak że
document.body.scrollHeight = window.pageYOffset + screen height in pixels
na końcu strony (na Androida).
14
Alternatywa window.scrollMaxY
:
document.documentElement.scrollHeight - document.documentElement.clientHeight
daje taki sam wynik jak window.scrollMaxY
z IE7, IE8, ff3.5, Safari 4, Opera, Google Chrome 10 3 pod DOCTYPE XHTML 1.0 Transitional.
3
dwa lata później ...
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
Powiązane problemy
- 1. Alternatywy dla Bootstrap dla Railsów
- 2. Darmowe alternatywy dla PowerGREP
- 3. Alternatywy dla wzoru singleton?
- 4. Alternatywy dla marynowania
- 5. Alternatywy dla TOAD (Linux)
- 6. Optymalizowanie alternatywy dla DateTime.Now
- 7. Alternatywy dla WCF
- 8. Darmowe alternatywy dla Kodów?
- 9. Alternatywy dla @VisibleForTesting
- 10. Alternatywy dla YQL
- 11. Alternatywy dla JUnit
- 12. Alternatywy dla chmurnego CDN?
- 13. Szukałem alternatywy dla JasperReports
- 14. Alternatywy dla Inflector.Net
- 15. Alternatywy dla ERB
- 16. Alternatywy dla iframe srcdoc?
- 17. Alternatywy dla serwera ArcGIS
- 18. Alternatywy dla członkostwa .Net
- 19. Alternatywne alternatywy dla DbUnit.NET
- 20. Alternatywy dla popen/pclose?
- 21. Alternatywy dla selekcji wiśni
- 22. Alternatywy dla JasperReports i BIRT
- 23. T-SQL dla każdej alternatywy?
- 24. Alternatywy dla statystyk :: zmiana kształtu
- 25. Jakie są alternatywy dla IRB?
- 26. Poszukuję szybszej alternatywy dla ImageIO
- 27. Alternatywy dla biblioteki JCIFS NTLM
- 28. Jakie są alternatywy dla PlayN?
- 29. Alternatywy dla hierarchii głębokiego dziedziczenia?
- 30. Alternatywy dla pętli w R?
Dziękuję dobrą sir. Chciałbym wiedzieć, czy są jakieś minusy w używaniu tej metody. Właśnie testowałem to w chrome/firefox i działa! – swajak
Próba zaimplementowania go przeciwko 'window.scrollY' zauważyłem, że w chrome przynajmniej' window.scrollY' jest wysoce precyzyjnym floatem, a 'scrollHeight' i' clientHeight' są liczbami całkowitymi, więc musiałem "Math.round"() 'to – Kaiido