I want to select the contents of a DIV (like highlight when you click and drag) when the user clicks on a button. The (hidden) div contains text that needs to be dragged to a 3rd party app outside the browser as input. In other words: I want to simulate the user selecting the contents of a textarea, click and dragging it to another app.
I'm using the PrototypeJS framework, and I came this far:
- put an mousedown observer on the button that needs to be pressed.
I've searched pretty hard already to find a way to select text in an html element, but couldn't find anything. The Prototype API doesn't seem to have a good function that can select the contents of a textarea or an element. It does have Form.Element.select() but that only works on input fields apparently.
Can someone help me out?