Some browswers were not putting cursor at beginning of message body after focus
authorpdontthink <pdontthink@7612ce4b-ef26-0410-bec9-ea0150e637f0>
Mon, 27 May 2019 21:54:59 +0000 (21:54 +0000)
committerpdontthink <pdontthink@7612ce4b-ef26-0410-bec9-ea0150e637f0>
Mon, 27 May 2019 21:54:59 +0000 (21:54 +0000)
git-svn-id: https://svn.code.sf.net/p/squirrelmail/code/trunk/squirrelmail@14824 7612ce4b-ef26-0410-bec9-ea0150e637f0

templates/default/js/default.js

index ad244923b3d4a95c1dfb454a1507b15731c0434f..4f19c96ae120db8124530306944025b7d4502d4c 100644 (file)
@@ -247,6 +247,17 @@ function sendMDN() {
 }
 
 var alreadyFocused = false;
 }
 
 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;
 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();
             document.forms['compose'].body.select();
         } else if (smaction == "focus") {
             document.forms['compose'].body.focus();
+            cursorToTop(document.forms['compose'].body);
         }
     } else {
     /*
         }
     } else {
     /*