文本编辑器(ckeditor)无法在我的DIV框内工作

时间:2010-10-01 21:42:00

标签: javascript jquery html ckeditor

您好我有一个div框在我的页面上打开,然后加载一个包含CKeditor的html文件来处理文本区域。问题是如果我在浏览器中查看html文件一切正常,我有所有的编辑选项。当我在我的JS脚本中使用它时,我什么也得不到。有人可以帮我吗?

执行此操作的JS代码在这里

        $(document).ready(function(){ 

              $('#'+divbox).load('../customer_rm/display_email_send.php', function() {
                      // once loaded 
                    CKEDITOR.replace( 'mail_body' );

,工作HTML文件在这里

    <!DOCTYPE html PUBLIC '-//W3C//DTD XHTML 1.0 Strict//EN' 'http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd'>
    <html xmlns='http://www.w3.org/1999/xhtml'>

    <head>
    <script type="text/javascript" src="ckeditor/ckeditor.js"></script>
    </head>
    <body>


    <style type='text/css'>
    table.t {border: 1px solid black}
    td, tr {border: 0}

    .bdr {
        border: 4px solid black ;
    }
    .white {
        background-color:#FFF ;
    }

    </style>

    <div align='center'>

    <br><br />

    <table id='t' width='700' border='2' bgcolor='#ccc'>
      <tr >
        <td width='20'>&nbsp;</td>
        <td width='50'>&nbsp;</td>
        <td width='50'>&nbsp;</td>
        <td >&nbsp;</td>
        <td width='20' >&nbsp;</td>    

      </tr>

      <tr>
        <td>&nbsp;</td>
        <td rowspan='3'>
        <input type='button'id='send' value='Send'
        style='width:60px; height:40px '
         /><hr>
        <input type='button' value='Close'
        style='width:60px; height:20px '                        onclick='fadeout()' 
         />
        </td>
        <td><input type='button' value='To :' /></td>
        <td><input type='text' class='white' id='mailto' size='80'  /></td>
        <td>&nbsp;</td>
      </tr> 

      <tr>
        <td>&nbsp;</td>

        <td><input type='button' value='Cc :' /></td>
        <td><input type='text' class='white' id='mailcc' name='mailcc' size='80' /></td>
        <td>&nbsp;</td>
      </tr>  
      <tr>
        <td>&nbsp;</td>

        <td><input type='button' value='Bcc :' id='bcc'  /></td>
        <td><input type='text' class='white' id='mailbcc' size='80' /></td>
        <td>&nbsp;</td>
      </tr>  
      <tr>
        <td>&nbsp;</td>
        <td><input type='button' value='Subject'
        style='width:60px; height:20px '                        onclick='fadeout()' 
         /></td>
        <td colspan='2'><input type='text' class='white' id='subject' size='89' /></td>


        <td>&nbsp;</td>
      </tr>  
      <tr>
        <td>&nbsp;</td>
        <td colspan='3'>
          <textarea  id='mail_body'  class='white'  style='height:380px; width:600px; bgcolor:#fff ' >
          </textarea>
        </td>
        <td>&nbsp;</td>
      </tr>  
      <tr>
        <td>&nbsp;</td>
        <td>&nbsp;</td>
        <td>&nbsp;</td>
        <td>&nbsp;</td>
        <td>&nbsp;</td>
      </tr>  
      <tr>
        <td>&nbsp;</td>
        <td>&nbsp;</td>
        <td>&nbsp;</td>
        <td>&nbsp;</td>
        <td>&nbsp;</td>
      </tr>  

     </table>


    </div>

1 个答案:

答案 0 :(得分:1)

为什么不使用Jquery来调用CKEditor来替换你的div ......看起来更简单:

$( 'textarea' ).ckeditor();

参考此处:http://ckeditor.com/blog/CKEditor_for_jQuery