Happy New Year
[squirrelmail.git] / templates / default / js / default.js
index f55517262958133507495129c55269f1dac338ec..109d5afa03819240c6727c76161512431433af88 100644 (file)
@@ -1,7 +1,7 @@
 /**
  * This array is used to remember mark status of rows in browse mode
  *
- * @copyright 2005-2018 The SquirrelMail Project Team
+ * @copyright 2005-2020 The SquirrelMail Project Team
  * @license http://opensource.org/licenses/gpl-license.php GNU Public License
  * @version $Id$
  */
@@ -247,6 +247,17 @@ function sendMDN() {
 }
 
 var alreadyFocused = false;
+
+function cursorToTop(element) {
+    if (typeof element.selectionStart == 'number')
+        element.selectionStart = element.selectionEnd = 0;
+    else if (typeof element.createTextRange != 'undefined') {
+        var selectionRange = element.createTextRange();
+        selectionRange.moveStart('character', 0);
+        selectionRange.select();
+    }
+}
+
 function checkForm(smaction) {
 
     if (alreadyFocused) return;
@@ -259,6 +270,7 @@ function checkForm(smaction) {
             document.forms['compose'].body.select();
         } else if (smaction == "focus") {
             document.forms['compose'].body.focus();
+            cursorToTop(document.forms['compose'].body);
         }
     } else {
     /*