Professional Documents
Culture Documents
My Style
My Style
selectionStart; var end = textarea.selectionEnd; var sel = textarea.value.substring(start, end); var text = buka + sel + tutup; var textarea = document.getElementsByTagName('textarea')[2]; if (document.selection && textarea.tagName == 'textarea') { /*IE textarea support*/ textarea.focus(); sel = document.selection.createRange(); sel.text = text; textarea.focus(); } else if (textarea.selectionStart || textarea.selectionStart == '0') { /*MOZILLA/NETSCAPE support*/ startPos = textarea.selectionStart; endPos = textarea.selectionEnd; scrollTop = textarea.scrollTop; textarea.value = textarea.value.substring(0, startPos) + text + textarea .value.substring(endPos, textarea.value.length); textarea.focus(); textarea.selectionStart = startPos + text.length; textarea.selectionEnd = startPos + text.length; textarea.scrollTop = scrollTop; } else { /*IE input[type=text] and other browsers*/ textarea.value += text; textarea.focus(); textarea.value = textarea.value; /*forces cursor to end*/ }