YesYo.com MintState Forums
뒤로    YesYo.com MintState BBS > Tech > Javascript
검색
멤버이름    오토
비밀번호 
 

iframe게시판에 테이블 표넣기(이지윅 에디터)

페이지 정보

작성자 MintState 댓글 0건 조회 25,299회 작성일 08-11-17 17:53

본문

iframe게시판에 테이블 표넣기(이지윅 에디터)

http://www.phpschool.com/gnuboard4/bbs/board.php?bo_table=qna_html&wr_id=106481

<table id=A><TR><TD> 
<a href="javascript:insertTable()">[표넣어보기]</a> 
</TD></TR></TABLE> 

<IFRAME NAME='diframe' id="diframe" style="width:500px;height:200px; border: 1px solid #CCCCCC;" frameborder="0" style='border:1px solid #838383'></IFRAME> 
<script language=javascript> 
<!-- 
var doc = document.getElementById('diframe').contentWindow.document; 
doc.open(); 
doc.open("text/html"); 
doc.write("<html><head><style>body{font-size:10pt;font-family:굴림;}; p{margin-top:2px;margin-bottom:2px;}; P{margin-top:0px;margin-bottom:0px;}; table {border:1 solid C6C3C6};</style></head><body tormargin=0 leftmargin=0 marginheight=0 marginwidth=0></body></html>"); 
doc.close(); 
doc.designMode = "on"; 
//--> 
</script> 


<script language=javascript> 
<!-- 
function insertTable(){ 
    document.all['crtTable'].style.display = ''; 
} 
function closeeditBox(){ 
    document.all['crtTable'].style.display = 'none';  
} 
//--> 
</script> 
<script language=javascript> 
<!-- 
//에디터에 테이블 표 넣기 테스트 
var intRowNum = 10; 
var intColNum = 10; 
var X , Y; 
X = Y = -1; 
function SetTableSize(iX, iY) { 
    tdim.innerText = (iX + 1) + " × " + (iY + 1); 

    var objTmp; 

    for (var i=X+1; i<=iX; i++) { 
        for (var j=0; j<=Y; j++) { 
            arrTableRef[i][j].bgColor = "E991F2"; 
        } 
    } 

    for (var j=Y+1; j<=iY; j++) { 
        for (var i=0; i<=X; i++) { 
            arrTableRef[i][j].bgColor = "E991F2"; 
        } 
    } 

    for (var i=X+1; i<=iX; i++) { 
        for (var j=Y+1; j<=iY; j++) { 
            arrTableRef[i][j].bgColor = "E991F2"; 
        } 
    } 

    for (var i=iX+1; i<=X; i++) { 
        for (var j=0; j<=iY; j++) { 
            arrTableRef[i][j].bgColor = "#FFFFFF"; 
        } 
    } 

    for (var j=iY+1; j<=Y; j++) { 
        for (var i=0; i<=iX; i++) { 
            arrTableRef[i][j].bgColor = "#FFFFFF"; 
        } 
    } 

    for (var i=iX+1; i<=X; i++) { 
        for (var j=iY+1; j<=Y; j++) { 
            arrTableRef[i][j].bgColor = "#FFFFFF"; 
        } 
    } 

    X = iX; 
    Y = iY; 
} 
function ReturnTableSize(){ 
    var tr = ""; 
    var trtd = ""; 
    for(var j=0; j<(X+1); j++){ 
        if(j==0){ 
            tr += "<tr>"; 
        } 
        tr += "<td>&nbsp;</td>"; 
        if(j==(X)){ 
            tr += "</tr>"; 
        } 
    } 
    for(var j=0; j<(Y+1); j++){ 
        trtd += tr; 
    } 
    var tabl = "<table cellpadding=0 cellpadding=0 border=1>"; 
        tabl += trtd; 
        tabl += "</table>"; 

    var doc = document.getElementById('diframe').contentWindow.document; 
    doc.write(tabl); 
    closeeditBox(); 
} 
//--> 
</script> 



<div id='crtTable' style='display:none' style='top:expression(A.offsetTop+12);left:expression(A.offsetLeft+12); position:absolute; visibility:show; z-index:1'> 
        <table id='CrtTable' border='2' cellpadding='0' cellspacing='2' align="center" bgcolor=#FFFFFF borderColor=threedface borderColorDark=threedface borderColorLight=threedface style="border-width:1; border-color:threedface;"> 
                <script> 
                    for (var i=0; i<intRowNum; i++) { 
                        document.write("<tr>"); 
                        for (var j=0; j<intColNum; j++) { 
                            document.write("<td width=10 height=11 id='id_" + j + "_" + i + "' onmouseover='SetTableSize(" + j + ", " + i + ")' onmousedown='ReturnTableSize()'><img src='images/1by1.gif'  border=0 width=1 height=1></td>"); 
                        } 
                        document.write("</tr>"); 
                    } 
                </script> 
                </table> 
        <script> 

        var arrTableRef = new Array(intRowNum); 

        for (var i=0; i<intRowNum; i++) { 
            arrTableRef[i] = new Array(intColNum); 
            for (var j=0; j<intColNum; j++) { 
                arrTableRef[i][j] = document.getElementById("id_"+i+"_"+j); 
            } 
        } 
        </script> 
        <table width='200' border='0' cellpadding='0' cellspacing='0'> 
        <tr><td width='80%' align='center'><div id=tdim></div></td> 
        <td width='*' align=right><a href='javascript:closeeditBox()'>close</a></td></tr> 
        </table> 
</div>


핵심은 이 부분입니다.

var doc = document.getElementById('diframe').contentWindow.document;
doc.write(tabl);

댓글목록

등록된 댓글이 없습니다.

Total 178건 2 페이지
게시물 검색
모바일 버전으로 보기
CopyRight ©2004 - 2024, YesYo.com MintState. ™