JavaScript Tips: How to Determine Browser Window Position
P粉218775965
2023-08-22 15:53:05
<p>For various silly reasons, I want to be able to detect a rectangular area of the browser window on the screen, including the title bar. </p>
<p>Is this possible, or is JavaScript only limited to the viewport of its page? </p>
<p><strong>Edit: </strong>I may not have expressed it clearly, but the viewport is the part of the page that is visible in the window. This may not be a commonly used term among browsers, but it's common in graphics. </p>
Please check the following properties:
(These properties do not give the size or position of the window, but they can be interpreted correctly when operating a system with multiple monitors)
For standards-compliant browsers:
X -
window.screenX
Y -
window.screenY
For IE browser:
X -
window.screenLeft
Y -
window.screenTop
Please keep in mind that implementations may vary. Please note multi-monitor setup...