function ShowSelection() { var textComponent = document.getElementById('MainTextArea'); var selectedText; var allText = document.getElementById('MainTextArea').value; // IE version if (document.selection != undefined) { textComponent.focus(); var sel = document.selection.createRange(); selectedText = sel.text; var slen = sel.moveStart('character', -oField.value.length); var elen = sel.text.length; allText.value = allText.value.substring(0, slen) + "" + selectedText; } // Mozilla version else if (textComponent.selectionStart != undefined) { var startPos = textComponent.selectionStart; var endPos = textComponent.selectionEnd; selectedText = textComponent.value.substring(startPos, endPos); allText = allText.substring(0, startPos) + "" + selectedText + "" + allText.substring(endPos,allText.length); } document.getElementById('MainTextArea').value = allText; }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)