search

Home  >  Q&A  >  body text

JavaScript Tips: How to Determine Browser Window Position

<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>
P粉218775965P粉218775965494 days ago663

reply all(2)I'll reply

  • P粉785957729

    P粉7859577292023-08-23 09:18:01

    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)

    reply
    0
  • P粉081360775

    P粉0813607752023-08-23 09:00:12

    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...

    reply
    0
  • Cancelreply