no,
getseletion only works in netscape navigator.
I have found some sort of solution, but it's far from perfect
But there are several problems:
- If the selected part is in the textarea field more than once, the first occurence is taken
- Only works on Internet Explorer as the commands for determining the selected part are different in netscape, i have noticed that this forum's post form uses the same system and works on both internet explorer and netscape. Must be some fine coding
Code:
if(navigator.userAgent.indexOf("MSIE")==-1)
{
alert("Deze functie werkt enkel met Microsoft Internet Explorer");
}
else if(navigator.userAgent.indexOf("MSIE")!==-1)
{
var selectie = document.selection.createRange().text;
}
var alletekst = document.getElementById(veld).createTextRange().text;
var selectielengte = document.selection.createRange().text.length;
var beginposselectie = alletekst.indexOf(selectie);
document.getElementById(veld).value = alletekst.substring(0,beginposselectie) + "["+tag+"]" + selectie + "[/"+tag+"]" + alletekst.substring((beginposselectie+selectielengte),alletekst.length);