Hi,
Here's a quick example. Try selecting some of the text in the textarea it should (hopefully) alert the bit of the text you selected
Tested in IE 6, FF 2 and Opera 9.Code:<html> <head> <script type="text/javascript"> onload = function() { document.getElementById('txt').onmouseup = function() { if (document.selection) { // for IE alert(document.selection.createRange().text); } else if (typeof this.selectionStart != 'undefined') { // for FF, Opera etc... alert(this.value.substring(this.selectionStart, this.selectionEnd)); } else { alert('Could not find selection'); } }; }; </script> </head> <body> <textarea id="txt" rows="10" cols="50">hello! please select me</textarea> </body> </html>




) alert the bit of the text you selected
Reply With Quote