일단 죄송합니다 ㅠㅜ 질문지침서가 있었군요ㅠㅠㅠ
동아리 게시판 관리 때문에 phpmyadmin만 잠깐 건드려본 초보입니다.
아래 그림에서 텍스트에디터의 빨간색 부분의 버튼을 클릭 시 글 작성이 완료되버리는 현상 때문에 여쭙게 되었습니다.
혼자 해결해보려고 했으나 전체 코드를 이해하질 못해서 해결이 안되는것 같습니다ㅠㅠ
전체 게시판에서 같은 현상이 발생하며 다른 브라우져와 다른 기기에서도 같은 현상이 발생합니다....
말씀해주신 버튼 설정 문제는 원래 몇년간 작동하던 부분이기에
아마 다른 문제일지도 모르겠지만 그 부분도 찾아보도록 하겠습니다. 답변 감사합니다!
먼저 TextEditor코드 부분은 아래와 같이 작성되어 있습니다.
function initEditor() {
var bHeader = "<style>P {margin-top:3px;margin-bottom:3px;margin-left:3;margin-right;3}</style>\n";
iText.document.open();
iText.document.write(bHeader);
iText.document.close();
iText.document.body.style.fontSize = "9pt";
iText.document.body.style.fontFamily = "굴림";
}
function TextEditorEvent(){
if (TextEditor.event.button==2){
var oSource = TextEditor.event.srcElement ;
if (!oSource.isTextEdit)
oSource = TextEditor.event.srcElement.parentTextEdit;
var strValue = TextEditor.event.srcElement.tagName; //선택된 부분의 태그 종류
if ((strValue == "IMG" || strValue == "HR") && oSource != null) {
var oTextRange = oSource.createTextRange();
}
var selectedRange = TextEditor.document.selection.createRange();
var edValue = selectedRange.htmlText;
var strX = TextEditor.event.x;
var strY = TextEditor.event.y+180;
if (strValue == "IMG")
strH = "180px";
else if (strValue == "HR" || strValue == "TABLE")
strH = "135px";
else
strH = "340px";
var strParam = "dialogLeft:" + strX + ";dialogTop:" + strY + ";"
strParam = strParam + "center:no;dialogWidth:150px; dialogHeight:" + strH + ";status:0;scroll:0; help:0;unadorned:yes;"
}
}
그다음 버튼을 눌러서 디버거를 실행해서 눌러보면 토글 버튼의 경우 아래와 같이 'type'속성에서 에러가 발생하며
일반 버튼의 경우 누르면 'createRange'속성을 가져올 수 없다고 나옵니다.
혹시 몰라서 전체 코드도 같이 올려놓겠습니다.
function loadTextToEditor() {
init();
TextEditor.document.body.innerHTML = document.all.tmpContent.value;
}
//초기화
function init() {
TextEditor.document.onmousedown = new Function("TextEditorEvent()");
iText = TextEditor;
iText.document.designMode = "On";
TextEditView.style.display="inline";
initEditor();
iText.document.body.innerHTML = "<P> </P>";
bLoad = true;
}
//기존글을 불러와서 편집
/*
function Edit(){
init();
TextEditView.style.display="inline";
TextEditor.document.body.innerHTML = document.all.tmpContent.value;
}
*/
//초기화면 스타일 설정
function initEditor() {
var bHeader = "<style>P {margin-top:3px;margin-bottom:3px;margin-left:3;margin-right;3}</style>\n";
iText.document.open();
iText.document.write(bHeader);
iText.document.close();
iText.document.body.style.fontSize = "9pt";
iText.document.body.style.fontFamily = "굴림";
}
function TextEditorEvent(){
if (TextEditor.event.button==2){
var oSource = TextEditor.event.srcElement ;
if (!oSource.isTextEdit)
oSource = TextEditor.event.srcElement.parentTextEdit;
var strValue = TextEditor.event.srcElement.tagName; //선택된 부분의 태그 종류
if ((strValue == "IMG" || strValue == "HR") && oSource != null) {
var oTextRange = oSource.createTextRange();
}
var selectedRange = TextEditor.document.selection.createRange();
var edValue = selectedRange.htmlText;
var strX = TextEditor.event.x;
var strY = TextEditor.event.y+180;
if (strValue == "IMG")
strH = "180px";
else if (strValue == "HR" || strValue == "TABLE")
strH = "135px";
else
strH = "340px";
var strParam = "dialogLeft:" + strX + ";dialogTop:" + strY + ";"
strParam = strParam + "center:no;dialogWidth:150px; dialogHeight:" + strH + ";status:0;scroll:0; help:0;unadorned:yes;"
}
}
/*수정 된 부분 */
//action event
/*
function check(param){
if(document.write.html_check[0].checked){
document.write.content.value = TextEditor.document.body.innerHTML;
if( !document.write.content.value ){
alert( "내용을 입력해주세요!^^");
TextEditor.document.body.focus();
return;
}
}else{
document.write.content.value = document.write.html_body.value;
if( !document.write.content.value ){
alert( "내용을 입력해주세요!^^");
document.write.html_body.focus();
return;
}
}
document.write.method='post';
document.write.action=param;
document.write.submit();
// document.write.enctype='multipart/form-data';
}
*/
//since 2002/03/17
function paste(param){
TextEditor.focus();
var sel = TextEditor.document.selection;
if (sel!=null) {
var rng = sel.createRange();
if (rng!=null)
rng.pasteHTML(param);
}
}
//since 2002.4.20
// 2004/02/11 by Parania
// html편집으로 바꾸면 포커스가 제대로 안되고 글이 안보이는 문제 해결
function layer_change(hidden_key,view_key){
document.all[hidden_key].style.display = "none";
document.all[view_key].style.display = "block";
if(hidden_key == "html_layer") {
TextEditor.document.body.innerHTML = document.all.html_body.value;
TextEditor.document.body.focus(); // 2004/02/11 by parania
}
else {
document.all.html_body.value = TextEditor.document.body.innerHTML;
document.all.html_body.focus(); // 2004/02/11 by parania
}
}
/*수정 된 부분 */
function ButtonUp(param) {
param.style.border="1px outset";
param.style.background="#D4D4D4";
}
function ButtonOut(param) {
param.style.border="";
param.style.background="";
}
function MenuOver(param) {
param.style.fontColor="white";
param.style.backgroundColor="navy";
}
function MenuOut(param) {
param.style.fontcolor="white";
param.style.backgroundColor="#C0C0C0";
}
/*
* 2004/02/11 comment by parania
* 글꼴과 글자크기를 바꿀 경우 적용되는 함수
*/
/*
* 2004/02/11 modified by parania
* 선택부분이 없으면 메시지를 출력한다.
*/
function block_style(o, cmd) {
if (TextEditor.document.selection.type == "None")
{
alert("먼저 스타일을 바꿀부분을 지정하세요.");
return;
}
var ed=TextEditor.document.selection.createRange();
ed.execCommand(cmd, false, o.value);
}
/*
* 2004/02/11 comment by parania
* 글꼴, 글자크기를 제외한 메뉴를 선택할 경우 적용되는 함수
*/
/*
* 2004/02/11 modified by parania
* 볼드, 이탤릭, 밑줄은 선택부분이 없으면 메시지를 출력한다.
*/
function SelectionCommand(Btn, cmd) {
// 볼드, 이탤릭, 밑줄 변환인데 텍스트 선택이 없을경우
if ((cmd == "Bold" || cmd == "Italic" || cmd == "Underline") && TextEditor.document.selection.type == "None")
{
alert("스타일을 바꿀 부분을 먼저 선택하세요.");
return;
}
TextEditor.focus();
var EdRange=TextEditor.document.selection.createRange();
EdRange.execCommand(cmd);
}
/*
function ChFontColor(param,cmd){
var ed
ed = TextEditor.document.selection.createRange();
ed.execCommand(cmd, false, param);
}*/
/** modified by neoburi-Inkuk*/
// 2004/02/11 modified by parania
// 선택이 없을 경우 메시지 출력
// 색깔 테이블 파일 변경(창크기도 변경)
function ChFontColor(cmd){
if (TextEditor.document.selection.type == "None")
{
alert("먼저 색을 바꿀부분을 지정하세요.");
return;
}
var ed
var value = showModalDialog( "/htmleditor/include/selcolor.html",
"",
"font-family:Verdana; font-size:12;dialogWidth:25em; dialogHeight:36em;status:no;help:no;self-close:no" );
if( value != null ){
ed = TextEditor.document.selection.createRange();
ed.execCommand(cmd, true, value);
}
TextEditor.document.body.focus();
}
function OpenWinInsertImage(URL) {
var str;
var scrWidth = (screen.availWidth / 2 ) - 200;
var scrHeight = (screen.availHeight / 2) - 200;
str="'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,copyhistory=no,";
str=str+"width=400";
str=str+",height=370',top="+scrHeight+",left="+scrWidth;
wopen = window.open(URL,'remote',str);
}
제가 미진해서 간단한 문제인데도 해결을 못하고 있는지도 모르겠군요ㅠㅠㅠ
시간 들여 읽어주신 분들께 감사드리며 혹시 해결책을 제시해주시면 정말 감사하겠습니다ㅠㅠㅠㅠ
오늘 낮은 따뜻하다고 하니 점심 맛있게 드시길 바라며 좋은 하루 되시길 바랍니다^^.