var tempArea = document.getElementById('MainText').innerHTML; var textComponent = document.getElementById(textbox); var selectedText; var allText = textComponent.value; // IE version if (document.selection != undefined) { //I dont care about IE } // Mozilla version else if (textComponent.selectionStart != undefined) { var startPos = textComponent.selectionStart; var endPos = textComponent.selectionEnd; selectedText = textComponent.value.substring(startPos, endPos); if (selectedText.search(arguments[1]) == -1 && selectedText.search(arguments[2]) == -1) allText = allText.substring(0, startPos) + arguments[1] + selectedText + arguments[2] + allText.substring(endPos,allText.length); } document.getElementById(textbox).value = allText;
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)