diff --git a/lib/scripts/textselection.js b/lib/scripts/textselection.js index 537e8d3481bb3211f0b4bbd1a4d4897351a2bc2a..f005fa3da9d151e69f68437b2a045ba2e0cd8e6b 100644 --- a/lib/scripts/textselection.js +++ b/lib/scripts/textselection.js @@ -14,6 +14,7 @@ function selection_class(){ this.end = 0; this.obj = null; this.rangeCopy = null; + this.scroll = 0; this.getLength = function(){ return this.end - this.start; @@ -41,8 +42,9 @@ function getSelection(textArea) { textArea.focus(); if(document.getSelection) { // Mozilla et al. - sel.start = textArea.selectionStart; - sel.end = textArea.selectionEnd; + sel.start = textArea.selectionStart; + sel.end = textArea.selectionEnd; + sel.scroll = textArea.scrollTop; } else if(document.selection) { // MSIE // The current selection var range = document.selection.createRange(); @@ -72,6 +74,7 @@ function setSelection(selection){ if(document.getSelection){ // FF // what a pleasure in FF ;) selection.obj.setSelectionRange(selection.start,selection.end); + if(selection.scroll) selection.obj.scrollTop = selection.scroll; } else if(document.selection) { // IE // count number of newlines in str to work around stupid IE selection bug var countNL = function(str) {