Dynamically Positioning a layer
-
I am aC++ and php programmer/scriptor (sp?) but know little about javascript and the document object model. How do I dynamically find the the top and left values (IN PIXELS) of an object with respect to the top left of the browser window. I use tables to format pages so objects can have parents, grandparents, great-grandparents,..etc. The clientLeft and offsetLeft in conjunction with the offsetWidth dont give me the values I need to set the proper location. I need a way to find the position with respect to the top left corner of the client area of the IE Explorer browser window. I have searched the msdn and am not finding the answer. Thanks a million.
-
I am aC++ and php programmer/scriptor (sp?) but know little about javascript and the document object model. How do I dynamically find the the top and left values (IN PIXELS) of an object with respect to the top left of the browser window. I use tables to format pages so objects can have parents, grandparents, great-grandparents,..etc. The clientLeft and offsetLeft in conjunction with the offsetWidth dont give me the values I need to set the proper location. I need a way to find the position with respect to the top left corner of the client area of the IE Explorer browser window. I have searched the msdn and am not finding the answer. Thanks a million.
Dear CPian, in the HTML world, all tags have a STYLE called "position". The "position" style can have a few different values. The 3 most used that you should be aware of are: inline absolute relative The default one is INLINE which allows the HTML elements to be rendered as they are found within the HTML code. In other words they follow the flow of the code in respect of their parent element. The ABSOLUTE positioning will ignore the hierarchy for of the element(in the HTML code) to wich is applied and position the element to exact coordinates having as origin the most top and most left of the browser wndow. This is why you will notice that all asolutely positioned elements also have a LEFT and a TOP style, style attributes that take as values numbers in pixels, picas, ems and percentages and a few others that my mind is missing now. So an element coded as such: <DIV style="position:absolute; top:100px; left:100px;">I AM ABSOLUTELY POSITIONED</DIV> will have its origin(top left corner of the DIV) to the coordinate 100,100 discarding any parent elements. No matter where it is found within the code, its position wouldn't change. The RELATIVE positioning is the same with the ABSOLUTE with one main difference. It uses as an origin its parent elemets top most and left most position instead of the browser top most and left most position. Hope I helped. :P theJazzyBrain
Excellence is not an act, but a habit!
Aristotle