Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6354119
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T22:31:35+00:00 2026-05-24T22:31:35+00:00

Based on answers from a previous question , both refer to mouse positions (x

  • 0

Based on answers from a previous question, both refer to mouse positions (x and y coordinates).

  • relative to the document and
  • relative to the viewport.

I have read through an article on QuirksMode, however I think I may be missing something. I have put together these two diagrams to help me in my understanding. Is my analysis correct?

enter image description here

Now scroll the document 250px…

enter image description here

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T22:31:35+00:00Added an answer on May 24, 2026 at 10:31 pm

    Your analysis is correct (and those are very nice diagrams!)

    However regarding your other post, they’re a bit more information than is necessary.

    You just need to understand that there is a document and viewport. The document is stationary and the viewport moves with you (and has a scroll offset).

    In principle, you could place your dialog window relative to either of these. Let’s pretend the dialog is a simple division element:

    <body>
    <button id="save">Save</button>
    <div id="dialog" style="position:absolute;">Are you sure?</div>
    </body>
    

    And let’s say you want to position that element relative to your button when clicked. You could use the document:

    <script>
    document.getElementById("save").onclick = function(e) {
      var dialog = document.getElementById("dialog");
    
      dialog.style.top = e.pageY + "px";
      /*
      pageY gives the position of the mouse relative to the
      document, when this event occurred.
      */
    };
    </script>
    

    Or you could use the viewport:

    <script>
    document.getElementById("save").onclick = function(e) {
      var dialog = document.getElementById("dialog");
    
      dialog.style.top = e.clientY + window.pageYOffset + "px";
      /*
      clientY gives the position of the mouse relative to
      the viewport, when this event occurred. And pageYOffset
      is the distance the user has scrolled.
      */
    };
    </script>
    

    You could even use the button itself. This has the added benefit of giving you a consistent position, regardless of where exactly the user clicked:

    <script>
    document.getElementById("save").onclick = function(e) {
      var dialog = document.getElementById("dialog");
    
      dialog.style.top = document.getElementById("save").offsetTop + "px";
      /*
      offsetTop gives the position of the button, relative to its nearest
      positioned ancestor. If the element is deeply nested, you may need
      to do additional calculations. (jQuery's "offset" method will do this
      for you).
      */
    };
    </script>
    

    To apply that last method when you’re using jQuery’s dialog class, you can simply do this:

    <script>
      $("#save").click(function(e) {
        $("#dialog").dialog({
          position: {
            my: "top",
            at: "bottom",
            of: $("#save")
          }
          /*
          See this: http://docs.jquery.com/UI/API/1.8/Position
          */
        });
      });
    </script>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Following on from a previous question . Lets say I have two checkboxes on
Based on some answers to this question it appears that +alloc does some behind-the-scenes
Update: Based on a couple of the answers I have received, I just want
based on the answer to my previous question by BlausC i am now able
Edit: Below is my working code based on the feedback/answers I recieved. This question
I posted a previous question about generating a bezier curve based on only the
In a previous question I asked how I could sum up a total based
Based on answer to my previous question, I would like to ask one more
Follow up to a previous question , I have some code that needs to
UPDATE: Solved. Thanks BusyMark! EDIT: This is revised based on the answer below from

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.