/* Functions related to cursor */ var POS_END = -10; function SetCursorPosition(name, beginning, end) { var obj = $(name); if (typeof(beginning) == "undefined") beginning = 0; if (beginning == POS_END) beginning = obj.value.length; if (typeof(end) == "undefined") end = beginning; if (obj.setSelectionRange) { //For IE obj.focus(); obj.setSelectionRange(beginning, end); return null; } else if (obj.createTextRange) { //For Firefox var range = obj.createTextRange(); range.collapse(true); range.moveEnd('character', end); range.moveStart('character', beginning); range.select(); return range; } }
|