私はwindow.pageYOffset & window.scrollMaxYを使用して現在のページの進行状況を計算しようとしています。このアプローチはFF3.5で動作しますが、Webkit window.scrollMaxYは未定義です。window.scrollMaxYの代替品ですか?
9
A
答えて
2
私は(Android上)ページの最後にdocument.body.scrollHeight
document.body.scrollHeight = window.pageYOffset + screen height in pixels
ように離れて持っています。 window.scrollMaxY
へ
14
オルタナティブ:
document.documentElement.scrollHeight - document.documentElement.clientHeight
は暫定DOCTYPEをXHTML 1.0の下でIE7、IE8とwindow.scrollMaxY
、ff3.5、サファリ4、オペラ10、Google Chromeの3と同じ結果になります。
3
2年後...
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
関連する問題
- 1. Scipyのfsolveの代替品ですか?
- 2. iPhoneのMPMoviePlayerControllerの代替品ですか?
- 3. Hazelcastのオープンソースの代替品ですか?
- 4. NAnt代替品
- 5. 代替品
- 6. シャープアーキテクチャー代替品
- 7. JqueryUIの代替品ですか?
- 8. MEF:PRISMの代替品ですか?
- 9. SAS DI LAG1の代替品ですか?
- 10. バックグラウンドサイズの代替品ですか?
- 11. Starclusterの代替品ですか?
- 12. イオン展開の代替品ですか?
- 13. 960.gsグリッドシステムの代替品ですか?
- 14. バグハントの代替品ですか?
- 15. IntelliJ IDEAのMylyn代替品ですか?
- 16. BufferedOutputStreamの代替品ですか?
- 17. fancyboxの代替品ですか?
- 18. reCAPCTHAの代替品ですか?
- 19. Cローレベルプログラミングの代替品ですか?
- 20. Flashの代替品ですか?
- 21. WiXの代替品ですか?
- 22. libQGLViewerの代替品ですか?
- 23. DataGridはUWPの代替品ですか?
- 24. CSLA.NETの代替品ですか?
- 25. Dreamweaverの代替品ですか?
- 26. Flash Builder Burritoの代替品ですか?
- 27. fflush(stdin)の代替品ですか?
- 28. SRSPlusの代替品ですか?
- 29. Microsoft Index Serverの代替品ですか?
- 30. CKANの代替品
はあなたに良い先生に感謝します。私は、この方法を使うことには何か欠点があるかどうかを知りたいです。私はchrome/firefoxでそれをテストして、うまくいきます! – swajak
これを 'window.scrollY'に対して実装しようとしました。クロムで少なくとも' window.scrollY'は高精度floatですが、 'scrollHeight'と' clientHeight'は整数なので、 'Math.round () 'それ – Kaiido