/ Published in: JavaScript
Expand |
Embed | Plain Text
<script language=javascript> function getSelText() { Â Â Â Â var txt = ''; Â Â Â Â if (window.getSelection) Â Â Â Â { Â Â Â Â Â Â Â Â txt = window.getSelection(); Â Â Â Â Â Â Â Â Â Â Â Â } Â Â Â Â else if (document.getSelection) Â Â Â Â { Â Â Â Â Â Â Â Â txt = document.getSelection(); Â Â Â Â Â Â Â Â Â Â Â Â } Â Â Â Â else if (document.selection) Â Â Â Â { Â Â Â Â Â Â Â Â txt = document.selection.createRange().text; Â Â Â Â Â Â Â Â Â Â Â Â } Â Â Â Â else return; document.aform.selectedtext.value = txt; } </script> <input type="button" value="Get selection" onmousedown="getSelText()"> <form name=aform > <textarea name="selectedtext" rows="5" cols="20"></textarea> </form>
You need to login to post a comment.
