サイズあれこれ
横
- document.body.scrollLeft
- document.body.clientWidth
- pageXOffset
- innerWidth
縦
- document.body.scrollTop
- document.body.clientHeight
- pageYOffset
- innerHeight
Window( Frame )のスクリーン上の位置(X座標)
function getWinXOffset(){ if(window.scrollX) return window.scrollX; // Moziila if(window.pageXOffset) return window.pageXOffset; // Opera, NN4 if(document.documentElement && document.documentElement.scrollLeft){ // 以下 IE return document.documentElement.scrollLeft; } else if(document.body && document.body.scrollLeft){ return document.body.scrollLeft; } return 0; }
Window( Frame )のスクリーン上の位置(Y座標)
function getWinYOffset(){ if(window.scrollY) return window.scrollY; // Mozilla if(window.pageYOffset) return window.pageYOffset; // Opera, NN4 if(document.documentElement && document.documentElement.scrollTop){ // 以下 IE return document.documentElement.scrollTop; } else if(document.body && document.body.scrollTop){ return document.body.scrollTop; } return 0; }