Skip to content

Position of mouse

priya

priya

Asked Mar 11, 2015, 3:34 AM EDT1 answer
Share
LinkedInX
I am using web browser control.
in this there are so many paragraphs.
i want to find out the position of mouse in a particular paragraph. that in which paragraph mouse is present??? 
please help me.

1 Answer

Know the answer? Post it. Somebody with the same question will find it here.

  • Afzaal Ahmad Zeeshan
    0
    If you were to do this using the Web Control, then you would have required to first of all, determine how much user has scrolled down in the document, then at which location (using x and y of screen or application more specifically) the cursor resides, to determine according to font size which paragraph is there... or more specifically, a very bad case of doing this!


    But, if you were to use some sort of web development code, HTML and JavaScript, then you can find out which paragraph the user is currently having the mouse over. For example the following code, 


    $('p').mouseover(function () {
       var id = $(this).attr('id');
    }


    Now the id would have the ID of the paragraph element that the user has moused over, when the mouse would move to a next paragraph, value would change and so on. Note that this would use the ID of the element, so always be ready for undefined if there is no ID found. This is an easy way of doing this; by using JavaScript inside the web document to be loaded. 
    0