473,395 Members | 2,446 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

Top left coner of html control

Is it possible to find top left corner of a control using JavaScript?
As far as I know it is very easy to do if you use Grid layout while
designing a page. But if you are using flow layout I didn't find any method
to find top left corner of a control.

I see drop down calendars that drop right under control even though I
designed page in flow layout.
How do they do it?
Thank,
Shimon.
Nov 19 '05 #1
4 1687
Generally you'd put both controls into a panel, div, or table cell separated
by a <br> tag.
Here's a more detailed analysis of your options:
http://SteveOrr.net/articles/ControlPositioning.aspx

--
I hope this helps,
Steve C. Orr, MCSD, MVP
http://SteveOrr.net
"Shimon Sim" <sh**********@community.nospam> wrote in message
news:%2****************@tk2msftngp13.phx.gbl...
Is it possible to find top left corner of a control using JavaScript?
As far as I know it is very easy to do if you use Grid layout while
designing a page. But if you are using flow layout I didn't find any
method to find top left corner of a control.

I see drop down calendars that drop right under control even though I
designed page in flow layout.
How do they do it?
Thank,
Shimon.

Nov 19 '05 #2
Thanks for Steve's informative inputs

Hi Shimon,

For html elements in non-absolute layout html page, we need to use
recursive script function to get their absolute postion on the whole page.
For example:
function getAbsoluteLeft(oNode)
{
var oCurrentNode = oNode;
var iLeft = 0;
while(oNode != null && oCurrentNode.tagName != "BODY" )
{
iLeft += oCurrentNode.offsetLeft;
oCurrentNode=oCurrentNode.offsetParent;
}

return iLeft;
}

function getAbsoluteTop(oNode)
{
var oCurrentNode = oNode;
var iTop = 0;
while(oNode != null && oCurrentNode.tagName != "BODY")
{
iTop += oCurrentNode.offsetTop;
oCurrentNode = oCurrentNode.offsetParent;
}
return iTop; }

However, such scripts also depend on the browser's script model support,
I've test the above functions on IE6 and it works. Hope also helps.

Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)
Nov 19 '05 #3
Thank you
Shimon.
"Steven Cheng[MSFT]" <v-******@online.microsoft.com> wrote in message
news:VY**************@TK2MSFTNGXA01.phx.gbl...
Thanks for Steve's informative inputs

Hi Shimon,

For html elements in non-absolute layout html page, we need to use
recursive script function to get their absolute postion on the whole page.
For example:
function getAbsoluteLeft(oNode)
{
var oCurrentNode = oNode;
var iLeft = 0;
while(oNode != null && oCurrentNode.tagName != "BODY" )
{
iLeft += oCurrentNode.offsetLeft;
oCurrentNode=oCurrentNode.offsetParent;
}

return iLeft;
}

function getAbsoluteTop(oNode)
{
var oCurrentNode = oNode;
var iTop = 0;
while(oNode != null && oCurrentNode.tagName != "BODY")
{
iTop += oCurrentNode.offsetTop;
oCurrentNode = oCurrentNode.offsetParent;
}
return iTop; }

However, such scripts also depend on the browser's script model support,
I've test the above functions on IE6 and it works. Hope also helps.

Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)

Nov 19 '05 #4
You're welcome :-)

Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)

Nov 19 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
by: Wayne Wengert | last post by:
I use statements like LEFT(textstring,6) in my app. I have "Imports Microsoft.VisualBasic" at the top of the code but to use LEFT I have to code : Microsoft.VisualBasic.Left(sting, integer) If...
4
by: Harlan Messinger | last post by:
What is *supposed* to be the way to specify the horizontal offset of (a) the list item's marker and (b) the list item's content? In particular, see ...
6
by: DM | last post by:
Is there any way to left align the text in a server control button?
4
by: UJ | last post by:
I have a long list of items that the user will be able to select from. When they select an item, I'd like to have more detailed information appear on the right side of the screen. I've already got...
3
by: =?Utf-8?B?U3RldmVU?= | last post by:
I want to create tabs in the TabControl that are aligned on either the right or left side, but no text shows when doing this. Is there an issue here or a work around. Text for tabs on top or...
6
by: Samuel Rhodes | last post by:
Hi I am trying to write a code snippet that would display a '?' sign on the top left of a control. I do not want to hard code the positioning of the DIV which will contain that '?'. Is it...
5
by: Timeri | last post by:
This is a bit confusing until you actually see what I'm talking about but the main content of my page is not growing with the right column. I want the main content (left/larger column) to take into...
5
by: Neviton | last post by:
Hi this is the html to generate the behavior: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http:// www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.