<script>
function getSel()
{
var txt = '';
var foundIn = '';
if(window.getSelection)
{
txt = window.getSelection();
foundIn = 'window.getSelection()';
}else if(document.getSelection)
{
txt = document.getSelection();
foundIn = 'document.getSelection()';
}else if(document.selection)
{
txt = document.selection.createRange().text;
foundIn = 'document.selection.createRange()';
}else
return;
document.forms[0].selectedtext.value = 'Found in: ' + foundIn + '/n' + txt;
}
</script>
<form>
<textarea name="selectedtext" rows="5" cols="50">
</textarea><br>
<input type="button" value="Getselection" onmousedown="getSel()">
</form>
function getSel()
{
var txt = '';
var foundIn = '';
if(window.getSelection)
{
txt = window.getSelection();
foundIn = 'window.getSelection()';
}else if(document.getSelection)
{
txt = document.getSelection();
foundIn = 'document.getSelection()';
}else if(document.selection)
{
txt = document.selection.createRange().text;
foundIn = 'document.selection.createRange()';
}else
return;
document.forms[0].selectedtext.value = 'Found in: ' + foundIn + '/n' + txt;
}
</script>
<form>
<textarea name="selectedtext" rows="5" cols="50">
</textarea><br>
<input type="button" value="Getselection" onmousedown="getSel()">
</form>