Getting selection from textarea within a div -
09-20-2004
, 12:51 PM
I'm tring to get the user selected text from a textarea included in a div like this:
<head>
<script ...>
function GetSele()
{
var str = document.selection.createRange().text;
alert(str);
}
</script>
....
</head>
<body>
....
<form name="theform" action="theaction" method="POST">
....
....
<div id="win">
<a href=\"javascript:GetSele();\"><img src=\"animage.gif\"></a><br>
<textarea name=\"edit_text\"></textarea>
</div>
</form>
</body>
but the result is an empty string. Any suggestion?
thanks in advance! |