출처 : http://cafe.naver.com/bigcase.cafe?iframe_url=/ArticleRead.nhn%3Farticleid=188


<SCRIPT LANGUAGE="JavaScript">
        function storeCaret (textel){
                if (textel.createTextRange){
                  textel.caretPos = document.selection.createRange().duplicate();
                }
        }
        function insertatcaret (textel, text){
          //text = "<b>" + text + "</b>";
          text = text;        
                if (textel.createTextRange && textel.caretPos){
                  var caretPos = textel.caretPos;
                  caretPos.text = caretPos.text.charAt(caretPos.text.length - 1) == ' ' ? text + ' ' : text;
                }else{
                  textel.value  = textel.value  + text;
                }
        }
  </SCRIPT>

<form>
<textarea name="admin_contents_sms_value" ROWS="10" COLS="50" WRAP="soft" ONSELECT="storeCaret(this);" ONCLICK="storeCaret(this);" ONKEYUP="storeCaret(this);">원하는 위치에 원하는 문자 삽입</textarea>
<br>
<input type=text name=tem_Code value='입력하세요'>
<input type="button" value="삽입" onClick="insertatcaret(this.form.admin_contents_sms_value,this.form.tem_Code.value);">
</form>

+ Recent posts