473,586 Members | 2,491 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 9384
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*****@freeja vahelp.com> wrote in message
news:16******** *************** ***@posting.goo gle.com...
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
474
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 location on the PAGE. I know that I can see the X, Y coords for the click event relative to the ImageButton control, but this does no good for my...
20
17020
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. The others are free to go over ... (I already found that part) -> http://users.pandora.be/hebbrecht/jochen/c++/test.cpp
3
6460
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 coordinates of where the mouse was clicked relative to the <HTML>, and I know where my DIV is, so I can calculate which part of the image was clicked...
3
3598
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 purpose is to get the position of the mouse pointer on the bitmap. However, for some reason, the left (I also tried right) mouse clicks are not...
3
63339
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 display (in the status bar) the image coordinates of the mouse location. However, if I use the picturebox's MouseMove event, I am getting the...
3
1580
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 current coordinates of the cursor displayed as you are moving it around inside of the window. Thanks for any help with this.
7
3632
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 course, I can capture the event Click when someone clicks on the actual control, but not when they click off of it. Right now I am using the...
2
19579
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 1. Test if the mouse location is on top of the image
3
5174
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 is raised by my software at max 30 times per second. I have determined I should use a timer event on every 10 msec to raise the mouse event, but then...
4
2890
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 coordinates in a messagebox?
0
7841
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...
0
8204
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
8339
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...
0
8220
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...
0
6617
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...
0
5392
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...
0
3869
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2345
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
0
1184
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...

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.