function bindTabbing(event) { if (event.which || event.keyCode) { // 9 indicates TAB key. if ((event.which == 9) || (event.keyCode == 9)) { var subject = document.getElementById(txtProgramEditor); // Get the Editor textarea control. if (event.srcElement == subject) // If tab is pressed in the textarea then do the action. { // Creates a range and adds the Tab equivalent character in the text range. subject.selection = document.selection.createRange(); subject.selection.text = String.fromCharCode(9); event.returnValue = false; } if (subject.selectionStart || subject.selectionStart == '0') { var str = subject.value; var startIndex = subject.selectionStart; subject.value = str.substring(0, startIndex) + ' ' + str.substring(startIndex, str.length); subject.focus(); subject.selectionEnd = startIndex + 4; return false; } } } else { return true; } }
subject.selection = document.selection.createRange();
subject.selection = window.getSelection();
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)