Finding mouse coordinates

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Pallavi

    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
  • Fabian

    #2
    Re: Finding mouse coordinates

    Pallavi hu kiteb:
    [color=blue]
    > 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?[/color]

    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!
    AGAM69 menghadirkan inspirasi desain kreatif, solusi digital, pengembangan teknologi, serta inovasi modern untuk kebutuhan bisnis dan profesional.


    Comment

    • Richard Cornford

      #3
      Re: Finding mouse coordinates

      "Pallavi" <pallavi@freeja vahelp.com> wrote in message
      news:1674567f.0 312010413.21704 bc3@posting.goo gle.com...[color=blue]
      >Suppose I want to highlight a piece of text.[/color]

      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)?
      [color=blue]
      >I get the x & y co-ordinates on the screen. And using
      >dhtml I am able to highlight the text.[/color]

      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.
      [color=blue]
      >Then I try on another machine with different resolution.
      >I am unable to get the relative position on the screen.[/color]

      The relative position of what, and relative to what?
      [color=blue]
      >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?[/color]

      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.


      Comment

      Working...