在setfocus函数上处理文本框中的光标位置 [英] handling cursor position in textbox on setfocus function

查看:88
本文介绍了在setfocus函数上处理文本框中的光标位置的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在焦点移到文本框控件上时处理光标位置.例如,如果文本框中有4个单词,那么当我使用时
setfocus(ctrl).光标应放在文本框中第4个单词的末尾.任何机构可以帮助我... !!.plz请注意,这是一个Web应用程序

hi i want to handle the cursor position when the focus comes on textbox control.like if there are 4 words in textbox then when i use
setfocus(ctrl).the cursor should be placed at the end of the 4rth word in textbox.can any body help me...!!.plz note this is a web application

推荐答案

hii finaaly在文本框的onfocus事件上得到了名为此js函数的解决方案jst....

hii finaaly got the solution jst called this js function on onfocus event of textbox....

<script type="text/javascript">
      function SetCursorToTextEnd(textControlID) {
          var text = document.getElementById(textControlID);
          if (text != null && text.value.length > 0) {
              if (text.createTextRange) {
                  var range
  = text.createTextRange(); range.moveStart('character', text.value.length); range.collapse();
                  range.select();
              } else if (text.setSelectionRange) {
                  var textLength = text.value.length;
                  text.setSelectionRange(textLength, textLength);
              }
          }
      }
  </script>




我认为 [
Hi,

I think this[^] is what you are looking for...


这篇关于在setfocus函数上处理文本框中的光标位置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆