I would like to select text on the page by simulating a left mouse button down and drag it to a specified x,y location (in pixels)
Can this be done with JavaScript?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
I don’t think its possible to control the mouse in this way using JavaScript.
However, you can select parts of a document directly using JavaScript. For example:
would select the first h3 element.
Also see: http://www.quirksmode.org/dom/range_intro.html for more info about building ranges.
To select the entire body of a document, you can use:
To select the 3rd character of, say, the 4th paragraph in a document, try: