By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
437,712 Members | 2,116 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 437,712 IT Pros & Developers. It's quick & easy.

Finding mouse coordinates

P: n/a
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
Share this Question
Share on Google+
2 Replies


P: n/a
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

P: n/a
"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 discussion thread is closed

Replies have been disabled for this discussion.