473,396 Members | 1,683 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,396 software developers and data experts.

Finding mouse coordinates

Hello,

Suppose I want to highlight a piece of text. I get the x & y
co-ordinates on the screen. And using dhtml I am able to highlight the
text. Then I try on another machine with different resolution. I am
unable to get the relative position on the screen. Can anyone guide me
how to find the relative position on different screen resolutions?
Suppose i get the position on 1024 X 768. What would be that position
on 800 X 600 or 640 X 480?

TIA,

Pallavi
Jul 20 '05 #1
2 9364
Pallavi hu kiteb:
Hello,

Suppose I want to highlight a piece of text. I get the x & y
co-ordinates on the screen. And using dhtml I am able to highlight the
text. Then I try on another machine with different resolution. I am
unable to get the relative position on the screen. Can anyone guide me
how to find the relative position on different screen resolutions?
Suppose i get the position on 1024 X 768. What would be that position
on 800 X 600 or 640 X 480?


iirc, the x position on a 800 pixel wide display, relative to a 1024
pixel wide display, can be found by multiplying by 800/1024. However,
there are many issues associated with using the screen size of the guy
viewing your web page.
--
--
Fabian
Visit my website often and for long periods!
http://www.lajzar.co.uk

Jul 20 '05 #2
"Pallavi" <pa*****@freejavahelp.com> wrote in message
news:16**************************@posting.google.c om...
Suppose I want to highlight a piece of text.
What do you mean by "highlight"? Are you just altering the
presentational style of an element, wrapping some text in a new inserted
element or using the browser's text selection capabilities (where
available)?
I get the x & y co-ordinates on the screen. And using
dhtml I am able to highlight the text.
Do you mean the screen co-ordinates? Usually, for DHTML work, either the
viewport co-ordinates or (more likely) the co-ordinates within the HTML
page are more relevant (as control over the window size and position is
not achievable outside of the controlled environment of an Intranet, and
not always even then).

I don't see a need for knowing the co-ordinates of anything in order to
highlight some text, unless you are using Range objects to select text.
Then I try on another machine with different resolution.
I am unable to get the relative position on the screen.
The relative position of what, and relative to what?
Can anyone guide me how to find the relative position on
different screen resolutions? Suppose i get the
position on 1024 X 768. What would be that position
on 800 X 600 or 640 X 480?


Generally it is possible to write HTML, and the JavaScript to interact
with it, totally independently of screen resolution/window size (indeed
it is advisable to always do exactly that as the page author has no
knowledge or control over either (even when they may believe that they
have)). Unfortunately, it would probably be possible to write a small
book about acquiring and using the relative co-ordinates of HTML
elements, text nodes and pointing devices and that is a bit of an
unrealistic expectation from a Usenet response.

You will have to narrow the subject to what is relevant to you situation
by going to the effort of comprehensively explaining your situation,
probably to the extent of making existing HTML and JavaScript code
available (though that could be just a cut-down version that adequately
demonstrated the problem rather than including code that has no baring).

Richard.
Jul 20 '05 #3

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

Similar topics

1
by: TB | last post by:
Howdy... I have an asp.net web form with an ImageButton control on the form. When clicked, the ImageButton's click event handler is supposed to pass X and Y coordinates of the mouse click's...
20
by: Webdad | last post by:
Hi! I running my first year as industrial engineer (informatics) We have an assignment to do : .... create a playfield (matrix). Some places in that field are blocked, so you can't pass them....
3
by: Nick Wedd | last post by:
I have this <DIV id="canopy" onClick="myhandler(event.x,event.y); return false;"> <IMG border=0 height=66 width=292 src="gifs/top.gif"> </DIV> which works in IE. myhandler gets called with the...
3
by: mitsura | last post by:
Hi, I have included a small listing. The test program opens a panel and show a bitmap. What I want is to when the mouse is over the bitmap panel, I want to trap the left mouse click. The...
3
by: Tom | last post by:
I have a picturebox on my VB.NET form. The picturebox size mode is set to stretched. I then load an image into that form and display it. As the user moves the mouse over the form, I want to get and...
3
by: aam | last post by:
Hi. I am trying to find the cursor coordinates inside of a window, not a form. I would like to display the coordinates of the cursor when you click inside of the window. Either that, or have the...
7
by: RobKinney1 | last post by:
The subject line sounds a little funny, let me quickly explain: I have created a custom control using ComboBox. But inside my class, I need to know when the user does NOT click my control. Of...
2
by: quickcur | last post by:
Hi, I have html like this: <div id="myCanvas" style="border:10px, black;position:relative;height:250px;width:100%;"> <img id="p" src="p.jpg"> </div> When user click the mosue, I would like ...
3
by: wanwan | last post by:
I made a game with a window form that needs to record the mouse position to an array at 100 samples per second, so I use the mouse move event to do the job. The problem is the mouse move event...
4
by: =?Utf-8?B?Unlhbg==?= | last post by:
I have a winform containing a scrollable panel and a groupbox inside the panel. There is a button inside the groupbox. When that button is clicked; how do I capture and display the X and Y...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
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...

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.