我这里的一个项目要求能将一段文字插入到FreeTextBox当前光标的位置。这样可以做到吗?高手们帮帮忙啊

解决方案 »

  1.   

    插入指定HTML数据到编辑器光标位置 
      function InsertText(textToInsert) { 
        FTB_InsertText("",textToInsert); 
        .focus(); 
      } 
      

  2.   

      function   getCursorPosition(){   
      var   src   =   event.srcElement   
      var   oTR   =   src.createTextRange()   
      var   textLength   =   src.innerText.length   
      var   line,   char,   total,   cl   
      oTR.moveToPoint(window.event.x,   window.event.y)   
      oTR.moveStart("character",   -1*textLength)   
      cl   =   oTR.getClientRects()   
      line   =   cl.length   
      total   =   oTR.text.length   
      oTR.moveToPoint(cl[cl.length-1].left-2,   cl[cl.length-1].top-2)   
      oTR.moveStart("character",   -1*textLength)   
      char   =   total   -   oTR.text.length   
      alert("行:   "   +   line   +",   列:   "   +   char   +   ",   第   "   +   total   +   "   个字符");   
      }   
      

  3.   

    我查了FreeTextBox专有的取光标位置的方法:就是wuyq11提供的那种方案,但是不会用啊