最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - TinyMCE with div tag? - Stack Overflow

programmeradmin4浏览0评论

Below is my JSP code:

<tr>
      <td colspan="2">custEmail</td>
      <td colspan="5"><div id= "custEmail"><p><strong>Test</strong></p></div></td>
</tr>

Below is the code attaching the div with TinyMCE Editor

<script type="text/javascript" src="tinymce/tinymce.min.js"></script>
<script type="text/javascript">
tinyMCE.init({
        width : "640",
        mode : "exact",
        elements : "custEmail",
        theme : "advanced",
        plugins : "preview",
        readonly : true,
        theme_advanced_buttons1 : "forecolor,backcolor,|,justifyleft,justifycenter,justifyright,justifyfull,|,bullist,numlist,|,formatselect,fontselect,fontsizeselect,sub,sup,|,bold,italic,underline,strikethrough",
        theme_advanced_buttons2 : "",
        theme_advanced_buttons3 : "",
        theme_advanced_toolbar_location : "top",
        theme_advanced_toolbar_align : "left",
        theme_advanced_statusbar_location : "bottom",
        theme_advanced_resizing : true
    });
</script>

But on my HTML page, I see the content as:

<p><strong>Test</strong></p>

Instead of Bold Test. As soon as I change the following:

div id="custEmail" tag to textarea id="custEmail"

It works fine. Not sure if I need to have some setting for div tag?

Below is my JSP code:

<tr>
      <td colspan="2">custEmail</td>
      <td colspan="5"><div id= "custEmail"><p><strong>Test</strong></p></div></td>
</tr>

Below is the code attaching the div with TinyMCE Editor

<script type="text/javascript" src="tinymce/tinymce.min.js"></script>
<script type="text/javascript">
tinyMCE.init({
        width : "640",
        mode : "exact",
        elements : "custEmail",
        theme : "advanced",
        plugins : "preview",
        readonly : true,
        theme_advanced_buttons1 : "forecolor,backcolor,|,justifyleft,justifycenter,justifyright,justifyfull,|,bullist,numlist,|,formatselect,fontselect,fontsizeselect,sub,sup,|,bold,italic,underline,strikethrough",
        theme_advanced_buttons2 : "",
        theme_advanced_buttons3 : "",
        theme_advanced_toolbar_location : "top",
        theme_advanced_toolbar_align : "left",
        theme_advanced_statusbar_location : "bottom",
        theme_advanced_resizing : true
    });
</script>

But on my HTML page, I see the content as:

<p><strong>Test</strong></p>

Instead of Bold Test. As soon as I change the following:

div id="custEmail" tag to textarea id="custEmail"

It works fine. Not sure if I need to have some setting for div tag?

Share Improve this question edited Feb 7, 2015 at 10:46 emotality 13k4 gold badges42 silver badges60 bronze badges asked Nov 27, 2012 at 13:22 emillyemilly 10.5k36 gold badges110 silver badges183 bronze badges
Add a ment  | 

1 Answer 1

Reset to default 5

All you need to do is to set forced_root_block to 'div' :

tinyMCE.init({
        ...
        forced_root_block : 'div'
});
发布评论

评论列表(0)

  1. 暂无评论