473,802 Members | 2,432 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 1704
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**********@c ommunity.nospam > wrote in message
news:%2******** ********@tk2msf tngp13.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.ta gName != "BODY" )
{
iLeft += oCurrentNode.of fsetLeft;
oCurrentNode=oC urrentNode.offs etParent;
}

return iLeft;
}

function getAbsoluteTop( oNode)
{
var oCurrentNode = oNode;
var iTop = 0;
while(oNode != null && oCurrentNode.ta gName != "BODY")
{
iTop += oCurrentNode.of fsetTop;
oCurrentNode = oCurrentNode.of fsetParent;
}
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.m icrosoft.com> wrote in message
news:VY******** ******@TK2MSFTN GXA01.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.ta gName != "BODY" )
{
iLeft += oCurrentNode.of fsetLeft;
oCurrentNode=oC urrentNode.offs etParent;
}

return iLeft;
}

function getAbsoluteTop( oNode)
{
var oCurrentNode = oNode;
var iTop = 0;
while(oNode != null && oCurrentNode.ta gName != "BODY")
{
iTop += oCurrentNode.of fsetTop;
oCurrentNode = oCurrentNode.of fsetParent;
}
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
8430
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 I code just "Left" it is flagged as an error with the message "Public Overloads Property Left() As Integer has no parameters and its return type cannot be indexed"
4
8400
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 http://mywebpages.comcast.net/hmessinger/default.html which validates under Strict. Under IE6, Opera, and Firebird, the markers are indented as one would expect the default to be. What if I want them moved over to the left edge of the list? On the above page, there is no margin-left for...
6
12630
by: DM | last post by:
Is there any way to left align the text in a server control button?
4
1762
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 a datagrid set up with the clicking working correctly. Problem is, I'd like to have the list be scrollable but leave the info on the right alone. What can I put around the datagrid so that the entire thing becomes scrollable? TIA - Jeff.
3
3980
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 bottom are just fine. I'm using VS 2005. -- ----------- Thanks, Steve
6
2034
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 possible to somehow know the top, left position of the content rendered by a User Control in a asp page. For eg, assume the figure below as a web page and A and B as user controls
5
2719
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 account the right deck (right column) so that both end at the same place. *********************************************************** Here's the URL... http://www.siteiq.net/TEST/index-new.html ...
5
3547
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 xmlns="http://www.w3.org/1999/xhtml" > <body style="margin: 0px; padding: 0px;"> <div style="margin-left: 10px; float: left;"> <div id="test" style="background-color: red;"> test </div>
0
9699
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10302
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
10058
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9111
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7597
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5494
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5622
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4270
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2966
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.