Solved

Find y position of bottom of element on web page and determine how much space is left

Posted on 2006-06-10
2
330 Views
Last Modified: 2008-02-01
I need to be able to find the position of the bottom of a tabstrip on a webpage in order to determine how much space is left in the window clientheight space. Then I will add a division to what area is left based on the user's window size. This area will have a scroll bar and must be visible without using the browser scroll bar on the right.
The tabstrip is displayed. When a user clicks on a specific tab, a dynamic table will be displayed in the remaining area. The table is larger than the window size so the division around the table places a scrollbar at the bottom and right. I want to dynamically calculate this area no matter what the user's window size is.

TAB1    Tab2   Tab3 Tab4 Tab5
---------------------------------------------------------------------------------------------------------------------------------
table                                                                                                                                                          I    *
                                                                                                                                                                 I    *
                                                                                                                                                                 I    *
                                                                                                                              division right scroll bar        *
                                                                                                                                                                 I    *
division scroll bar---------------------------------------------------------------------------------------------------------------  *
browser scroll bar***********************************************************************

0
Comment
Question by:C_J_L
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 1

Accepted Solution

by:
sganjam earned 500 total points
ID: 16882297
function PosX(obj){
      var curleft = 0;
      if (obj.offsetParent)
      {
            while (obj.offsetParent)
            {
                  curleft += obj.offsetLeft
                  obj = obj.offsetParent;
            }
      }
      else if (obj.x)
            curleft += obj.x;
               return curleft;
}

function PosY(obj){
                var curtop = 0;
      if (obj.offsetParent)
      {
            while (obj.offsetParent)
            {
            curtop += obj.offsetTop
            obj = obj.offsetParent;
            }
      }
      else if (obj.y)
            curtop += obj.y;
      return curtop;
}

The above two functions will calculate the  X (from left) and Y (from top) position of the Top-Left corner of the object in pixels . You can then manipulate it by adding on the object width or height. Use the following:

obj.offsetheight (for height of the object)
obj.offsetwidth (for width of the object)

You can also use

document.body.offsetWidth
document.body.offsetHeight

For the screen width and height respectively. Just make sure to define an arbitrary width and height to the body tag.

If you wanted to for example, calculate the the position of an object from the right side of the screen:

offsetRight = document.body.offsetWidth - (offsetX + p.offsetWidth);
0
 

Author Comment

by:C_J_L
ID: 16883051
Hey, thanks a lot!
0

Featured Post

SharePoint Admin?

Enable Your Employees To Focus On The Core With Intuitive Onscreen Guidance That is With You At The Moment of Need.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
Boost your ability to deliver ambitious and competitive web apps by choosing the right JavaScript framework to best suit your project’s needs.
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…
Suggested Courses

615 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question