textarea 에 특정한 문자 넣기
페이지 정보
작성자 최고관리자 작성일 21-02-09 11:54 조회 17,895 댓글 0본문
참고 : http://kin.naver.com/qna/detail.nhn?d1id=1&dirId=1040202&docId=71785288&qb=7YGs66Gs7JeQ7IScIHNlbGVjdGlvbi5jcmVhdGVSYW5nZQ==&enc=utf8§ion=kin&rank=3&search_sort=0&spq=0&pid=RVGrnc5Y7tlssZxvcHRsssssssh-088857&sid=Us4rCHJvLDQAADtoE2M
<SCRIPT type="text/javascript">
<!--
function $(Element){
return document.getElementById(Element);
}
function set_tag_support(obj, prefix, postfix) {
if (document.getSelection) ts = document.getSelection();
else if (document.selection) ts = document.selection.createRange().text;
else if (window.getSelection) ts = window.getSelection();
if (ts != ""){ //IE
document.selection.createRange().text = prefix + ts + postfix;
}else {
if (obj.selectionStart == obj.selectionEnd){
if(/*@cc_on!@*/false){
obj.focus();
document.selection.createRange().duplicate().text = prefix + document.selection.createRange().duplicate().text + postfix;
document.selection.createRange().select();
}else{
var s1 = obj.value.substring(0, obj.selectionStart);
var s2 = obj.value.substring(obj.selectionStart);
obj.value = s1 + prefix + postfix + s2;
}
}else{
var s1 = obj.value.substring(0, obj.selectionStart);
var s2 = obj.value.substring(obj.selectionStart, obj.selectionEnd);
var s3 = obj.value.substring(obj.selectionEnd);
obj.value = s1 + prefix + s2 + postfix + s3;
}
}
obj.focus();
}
//-->
</SCRIPT>
<TEXTAREA name="memo" id="memo" ROWS="5" COLS="50"></TEXTAREA>
<INPUT TYPE="button" onclick="set_tag_support($('memo'), '111', '2222')" value="확인">
<SCRIPT type="text/javascript">
<!--
function $(Element){
return document.getElementById(Element);
}
function set_tag_support(obj, prefix, postfix) {
if (document.getSelection) ts = document.getSelection();
else if (document.selection) ts = document.selection.createRange().text;
else if (window.getSelection) ts = window.getSelection();
if (ts != ""){ //IE
document.selection.createRange().text = prefix + ts + postfix;
}else {
if (obj.selectionStart == obj.selectionEnd){
if(/*@cc_on!@*/false){
obj.focus();
document.selection.createRange().duplicate().text = prefix + document.selection.createRange().duplicate().text + postfix;
document.selection.createRange().select();
}else{
var s1 = obj.value.substring(0, obj.selectionStart);
var s2 = obj.value.substring(obj.selectionStart);
obj.value = s1 + prefix + postfix + s2;
}
}else{
var s1 = obj.value.substring(0, obj.selectionStart);
var s2 = obj.value.substring(obj.selectionStart, obj.selectionEnd);
var s3 = obj.value.substring(obj.selectionEnd);
obj.value = s1 + prefix + s2 + postfix + s3;
}
}
obj.focus();
}
//-->
</SCRIPT>
<TEXTAREA name="memo" id="memo" ROWS="5" COLS="50"></TEXTAREA>
<INPUT TYPE="button" onclick="set_tag_support($('memo'), '111', '2222')" value="확인">
댓글목록 0
등록된 댓글이 없습니다.