[Edge]。読取専用。→
Window のブラウザーのビューポートの上端から画面の上端までの垂直距離を CSS ピクセル数で返します。
注: screenY の別名である が、最近は新しいブラウザー間で実装されていました。これはもともと IE のみが対応していましたが、有名であるためあらゆる場所で導入されています。
Window | Window。 |
---|
数値。ブラウザーのビューポートの上端から画面の上端までの CSS ピクセル数に等しい数値です。
initialLeft = window.screenLeft + canvasElem.offsetLeft; initialTop = window.screenTop + canvasElem.offsetTop; function positionElem() { let newLeft = window.screenLeft + canvasElem.offsetLeft; let newTop = window.screenTop + canvasElem.offsetTop; let leftUpdate = initialLeft - newLeft; let topUpdate = initialTop - newTop; ctx.fillStyle = 'rgb(0, 0, 0)'; ctx.fillRect(0, 0, width, height); ctx.fillStyle = 'rgb(0, 0, 255)'; ctx.beginPath(); ctx.arc(leftUpdate + (width/2), topUpdate + (height/2) + 35, 50, degToRad(0), degToRad(360), false); ctx.fill(); pElem.textContent = 'Window.screenLeft: ' + window.screenLeft + ', Window.screenTop: ' + window.screenTop; window.requestAnimationFrame(positionElem); } window.requestAnimationFrame(positionElem);
これは screenX/screenY でもまったく同じように動作します。
W=window.open();
開いたウインドウを別画面にして、ウインドウの位置をずらして、
D=W.screenY //=210。(サンプル値)