Help on getting mouse position with javascript

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Panos
    New Member
    • Sep 2007
    • 4

    Help on getting mouse position with javascript

    Hi all,
    I am trying to find out a way to get the line in wich the mouse is when browsing a web page. All I could find is the position of the mouse in pixels but that's not what I need.
    For example while a user is reading a paragraph I need a script to get which character of the text the reader has selected. I mean in which line of the actual htm file is this character.
    Sorry if i'm not very clear.....

    Thanks!!!
  • Panos
    New Member
    • Sep 2007
    • 4

    #2
    Help on getting mouse position with javascript

    Hello everyone,
    I need to find a way to get the line where the mouse is pointing on the browser and then find that position (line number ) in the html file. I believe this is posible with javascript but I can't find out a way to accomplish it.

    Thanks!!

    Comment

    • gits
      Recognized Expert Moderator Expert
      • May 2007
      • 5390

      #3
      hi ...

      Threads merged ... please don't double post ... read the posting guidelines ...

      kind regards

      Comment

      • dmjpro
        Top Contributor
        • Jan 2007
        • 2476

        #4
        Originally posted by Panos
        Hello everyone,
        I need to find a way to get the line where the mouse is pointing on the browser and then find that position (line number ) in the html file. I believe this is posible with javascript but I can't find out a way to accomplish it.

        Thanks!!
        Nah!
        It is not possible with JavaScript.
        Anyway! why are you looking for that :-)

        Kind regards,
        Dmjpro.

        Comment

        • gits
          Recognized Expert Moderator Expert
          • May 2007
          • 5390

          #5
          hi ...

          it seems to me that you want to retrieve the selected characters on a page?

          kind regards

          Comment

          • dmjpro
            Top Contributor
            • Jan 2007
            • 2476

            #6
            If Gits is right then try with document.create TextRange or document.select ion

            Kind regards,
            Dmjpro.

            Comment

            • Panos
              New Member
              • Sep 2007
              • 4

              #7
              Thank you all for your tips but i'm not that experienced to use document.create TextRange, i'll try it out though. Here is why i need this kind of script:
              I want the user to be able to insert his personal comments on an e-book (or something like it).i would prefare to avoid using add ons cause i 'll probably mess it up (not experienced).
              So i'm using the WebBrowser component of visual studio 2005, which displays html with javascript properly, and can also add some extra hsndling like next page and so on(it is a desktop application).
              What i need is, when a user (for example) right clicks on the text displayed on the browser there would be a pop-up form with a field where he could add some comments. And when a user wants to view his comments they should be placed at the position where he right clicked...Just like if it was a real book...
              What i have found is only about how to get the mouse position in pixels.I could use this but it is quite patchwork...
              Any ideas??Perhaps with c#??

              Thanks allot!!!

              Comment

              Working...