From 747a6554ee0004b6c306ff7c9770749fe3021f3d Mon Sep 17 00:00:00 2001 From: gongfuxiang Date: Tue, 5 Jul 2022 17:44:32 +0800 Subject: [PATCH] =?UTF-8?q?=E5=85=AC=E5=85=B1js=E6=96=B0=E5=A2=9E=E9=BC=A0?= =?UTF-8?q?=E6=A0=87=E5=85=89=E6=A0=87=E4=BD=8D=E7=BD=AE=E6=96=B9=E6=B3=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- public/static/common/js/common.js | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/public/static/common/js/common.js b/public/static/common/js/common.js index 7779cdc93..b9441538f 100755 --- a/public/static/common/js/common.js +++ b/public/static/common/js/common.js @@ -2321,6 +2321,36 @@ function UrlUseCurrentHostHandle(url) return url; } +/** + * 获取鼠标光标位置 + * @author Devil + * @blog http://gong.gg/ + * @version 1.0.0 + * @date 2022-07-04 + * @desc description + * @param {[object]} e [元素对象] + */ +function CursorPos(e) +{ + var pos = 0; + if(typeof(e) == 'object') + { + var el = e.get(0); + if('selectionStart' in el) + { + pos = el.selectionStart; + } else if('selection' in document) + { + el.focus(); + var sel = document.selection.createRange(); + var sel_len = document.selection.createRange().text.length; + sel.moveStart('character', -el.value.length); + pos = sel.text.length - sel_len; + } + } + return pos; +} + // 公共数据操作 $(function()