Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > cursor coordinates relavtive to div

Reply
Thread Tools

cursor coordinates relavtive to div

 
 
=?Utf-8?B?cm9kY2hhcg==?=
Guest
Posts: n/a
 
      10-17-2007
hey all,
i'm using a mouseover event for my div and i was wondering how to get the
coordinates of the cursor relative to my DIV. For instance the top left
corner of my div, no matter where on the screen it is, is 0,0?

thanks,
rodchar
 
Reply With Quote
 
 
 
 
Mike Placentra II
Guest
Posts: n/a
 
      10-17-2007
You need to use JavaScript to find the mouse's coordinates. It's a bit
of a mess because of the differences between how browsers give you
cursor coordinates in JavaScript. I would suggest searching something
like "JavaScript cursor coordinates" in a search engine because there
are many resources and code examples on the internet, and it would be
better to find out from there than from me giving you a short example
that might not work perfectly. One example might not cover all
browsers or different versions of browsers, and I'm not too clear on
which browsers use what (for getting mouse coordinates).

These examples generally will give you coordinates relative to the
document, not relative to the <div>. You can calculate the location
relative to the <div> by difference of location of the <div> using
other JavaScript things. That's also messy because different browsers
give you the calculated locations of elements in different ways too.

If you don't get enough information that way and from others who
reply, you can give it a shot in comp.lang.javascript .

-Michael Placentra II


On Oct 17, 4:36 pm, rodchar <(E-Mail Removed)> wrote:
> hey all,
> i'm using a mouseover event for my div and i was wondering how to get the
> coordinates of the cursor relative to my DIV. For instance the top left
> corner of my div, no matter where on the screen it is, is 0,0?
>
> thanks,
> rodchar


 
Reply With Quote
 
 
 
 
=?Utf-8?B?cm9kY2hhcg==?=
Guest
Posts: n/a
 
      10-26-2007
thank you for the help.
rod.

"Mike Placentra II" wrote:

> You need to use JavaScript to find the mouse's coordinates. It's a bit
> of a mess because of the differences between how browsers give you
> cursor coordinates in JavaScript. I would suggest searching something
> like "JavaScript cursor coordinates" in a search engine because there
> are many resources and code examples on the internet, and it would be
> better to find out from there than from me giving you a short example
> that might not work perfectly. One example might not cover all
> browsers or different versions of browsers, and I'm not too clear on
> which browsers use what (for getting mouse coordinates).
>
> These examples generally will give you coordinates relative to the
> document, not relative to the <div>. You can calculate the location
> relative to the <div> by difference of location of the <div> using
> other JavaScript things. That's also messy because different browsers
> give you the calculated locations of elements in different ways too.
>
> If you don't get enough information that way and from others who
> reply, you can give it a shot in comp.lang.javascript .
>
> -Michael Placentra II
>
>
> On Oct 17, 4:36 pm, rodchar <(E-Mail Removed)> wrote:
> > hey all,
> > i'm using a mouseover event for my div and i was wondering how to get the
> > coordinates of the cursor relative to my DIV. For instance the top left
> > corner of my div, no matter where on the screen it is, is 0,0?
> >
> > thanks,
> > rodchar

>
>

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Searching for real-time display of screen x-y coordinates of cursor. SilentRunningPC Software 0 12-19-2011 09:00 PM
how to tell if cursor is sqlite.Cursor or psycopg2.Cursor dmaziuk Python 3 01-25-2011 04:52 AM
how to show x y coordinates of the cursor wai-tak sit HTML 5 09-09-2006 08:16 PM
Converting canvas coordinates to window coordinates in tkinter......... Suresh Kumar Python 0 07-04-2003 10:14 AM
Converting canvas coordinates to window coordinates....... Suresh Kumar Python 0 07-03-2003 04:53 AM



Advertisments