From babad50305f1b991f32209a7f2e3b72a5eefe5c7 Mon Sep 17 00:00:00 2001 From: pdontthink Date: Mon, 27 May 2019 21:54:59 +0000 Subject: [PATCH] Some browswers were not putting cursor at beginning of message body after focus git-svn-id: https://svn.code.sf.net/p/squirrelmail/code/trunk/squirrelmail@14824 7612ce4b-ef26-0410-bec9-ea0150e637f0 --- templates/default/js/default.js | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/templates/default/js/default.js b/templates/default/js/default.js index ad244923..4f19c96a 100644 --- a/templates/default/js/default.js +++ b/templates/default/js/default.js @@ -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 { /* -- 2.25.1