View Single Post
Old 09-10-2004, 06:34 AM   #3 (permalink)
DragonEye
Contributing Member
 
DragonEye's Avatar
 
Join Date: 10-13-03
Location: Belgium
Posts: 322
iTrader: 0 / 0%
Latest Blog:
None

DragonEye is liked by somebodyDragonEye is liked by somebodyDragonEye is liked by somebodyDragonEye is liked by somebodyDragonEye is liked by somebody
Send a message via MSN to DragonEye
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);
DragonEye is offline   Reply With Quote