Hi everybody!
I need a script, which calculates screen coordinates of given object (e.g. textbox or div). By "screen coordinates" I mean offset from upper left corner of the screen (not frame or browser window).
Thanks in advance.
11 5324 acoder 16,027
Recognized Expert Moderator MVP
Use the screenX/screenY properties.
hsriat 1,654
Recognized Expert Top Contributor
You won't be able to get that if the HTML is rendered itself. But if you have set the position, and left and top of the elements by CSS (or javascript), only then you would be able to retrieve the x and y coordinates as -
var x = parseInt(elementObj.style.left);
-
var y = parseInt(elementObj.style.top);
hsriat 1,654
Recognized Expert Top Contributor
Use the screenX/screenY properties.
And that was a really old post! ... :D Markus 6,050
Recognized Expert Expert
And that was a really old post! ...:D
Must've been bored.
Like me
acoder 16,027
Recognized Expert Moderator MVP
You won't be able to get that if the HTML is rendered itself. But if you have set the position, and left and top of the elements by CSS (or javascript), only then you would be able to retrieve the x and y coordinates as -
var x = parseInt(elementObj.style.left);
-
var y = parseInt(elementObj.style.top);
That would give you the x/y coordinates within the browser, not the screen
...and yes, it's an old post, but no-one answered it (poor thing!)
hsriat 1,654
Recognized Expert Top Contributor
Must've been bored.
Like me
But you don't reply in your own threads... :-/
hsriat 1,654
Recognized Expert Top Contributor
That would give you the x/y coordinates within the browser, not the screen
oh.. I see... good point..
So one can still calculate the browser's offset wrt the screen by doing - var offsetX = event.screenX - event.pageX; //(or clientX)
-
var offsetY = event.screenY - event.pageY; //(or clientY)
And then add that in x and y calculated above...
what say? :p
...and yes, it's an old post, but no-one answered it (poor thing!)
I hadn't joined by the time. :p
acoder 16,027
Recognized Expert Moderator MVP
oh.. I see... good point..
So one can still calculate the browser's offset wrt the screen by doing - var offsetX = event.screenX - event.pageX; //(or clientX)
-
var offsetY = event.screenY - event.pageY; //(or clientY)
And then add that in x and y calculated above...
what say? :p
screenX and screenY should be enough, see link.
I hadn't joined by the time. :p
Neither had I ;)
hsriat 1,654
Recognized Expert Top Contributor
screenX and screenY should be enough, see link.
But still, how would you tell what are the coordinates of a <div> element (for instance) wrt the screen? I'm not getting what you are trying to say.
This is what I understand from screenX and pageX: ![](/images/imgserve.php?url=http://www.riat.in/positions.png) Sign in to post your reply or Sign up for a free account.
Similar topics |
by: MLH |
last post by:
http://support.microsoft.com/default.aspx?scid=kb;en-us;100973
shows Function Screendump(). It is code that effectively does the
same thing as pressing SHIFT-PRTSCR on your keyboard. I am
trying to modify that code to copy only the screen image of the
current form to the clipboard, rather than the entire Access window.
Here is a small snippet from the function...
'---------------------------------------------------
' Get window handle...
|
by: phil cunningham |
last post by:
Hello,
I am looking for a good way to scale real objects on to the screen/printer
In our project, objects are created assuming the units are meters. For example, I may have a rectangluar shape that is 10.2m x7.3m
Part1
I want to be able to set a user defined scale (say 100 to 1) so that the box appears on screen at 10.2cm x 7.3cm (i.e. 100 times smaller than it really is)
This scale should be changeable to any value betwee 1 to 400...
|
by: Dan Sikorsky |
last post by:
How do you get the x,y pixel location of a textbox so that you can position
the Web Date Control popup nearby the associated textbox that will contain
the date selected by the Web Date Control?
--
Thank you kindly,
Dan Sikorsky BAB, BScE, MSC
|
by: ZorpiedoMan |
last post by:
Help... I need the screen coordinates of a control so I can place a pop
up form underneath it.
--Zorpy
*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
|
by: zoneal |
last post by:
OS: Win XP
Language: VB.net or C#
I have a program where I need to launch 2 separate instances of an App
called "Main.exe". Each instance will need to be piped to there own
video display. Both displays need to be running at a screen resolution
of 640x480.
I am able to force to screen resolution of the display that the app is
| |
by: steve |
last post by:
Hi All
I have textboxes within a TableLayoutpanel and I want to be able to position
an independant control adjacent to a selected textbox
This independent control allows selection of text to insert into the textbox
I am having trouble achieving this, see code below, the x position is too
far to the right and the y position is close to the bottom of the textbox
and I want it to be side by side.
|
by: Peter Oliphant |
last post by:
I'm programming using MS VS VC++ 2008 Express (Beta 2) in /Cli pure mode.
I've found the Screen class. With it I can very easily get the count and all
the data on the various Screens attached to a system, whether it be a single
screen or multiple screen system.
I believe the FromControl method of the Screen class can be used to
determine which Screen a Form is on. But I can't find how I can place or
move a Form onto the Screen of my...
|
by: raylopez99 |
last post by:
keywords: logical coordinates, page coordinates, world coordinates,
device coordinates, physical coordinates, screen coordinates, client
coordinates. offset rectangle. WYSIWYG rubber rectangle problem,
bounded rectangle problem. PointToClient, PointToScreen
Beware this newbie trap for the unwary. It goes by various names (in
some old MFC literature I saw some of the keywords above). Whenever
doing comparisons between points,...
|
by: raylopez99 |
last post by:
I have a logical drawing space much bigger than the viewport (the
screen) and I'd like to center the viewport (the screen) to be at the
center of the logical drawing space. After following the excellent
transforms specified on Bob Powell's site, I still wonder if there's
an easier way of centering it than the following procedure?
Here is what I do now (it's awkward but it works):
1) I follow the transforms specified on Bob Powell's...
|
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...
|
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
| |
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...
|
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...
|
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...
|
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...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |
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
| |