For various silly reasons, I'd like to be able to detect the rectangle of the browser window on screen. Title bar and all.
Is this possible, or is JavaScript limited to the view port of its page?
Edit: I may have been unclear, but view port is the portion of the page that's visible in the window. This may not be a term commonly used with browsers, but it's common in graphics.
The screenX property returns the horizontal coordinate (according to the users computer screen) of the mouse pointer when an event was triggered. Tip: To get the vertical coordinate (according to the screen) of the mouse pointer, use the screenY property. Note: This property is read-only.
jQuery . offset() will get the current coordinates of the first element, or set the coordinates of every element, in the set of matched elements, relative to the document.
Definition and Usage The screenX property returns the x (horizontal) coordinate of a window, relative to the screen.
For standards compliant browsers:
X - window.screenX
Y - window.screenY
For IE:
X - window.screenLeft
Y - window.screenTop
Keep in mind, implementations vary. Beware of multi-monitor setups...
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With