aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/lib/scripts/textselection.js
diff options
context:
space:
mode:
Diffstat (limited to 'lib/scripts/textselection.js')
-rw-r--r--lib/scripts/textselection.js7
1 files changed, 5 insertions, 2 deletions
diff --git a/lib/scripts/textselection.js b/lib/scripts/textselection.js
index 537e8d348..f005fa3da 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) {