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

asp.net - TinyMCE wraps my text in <p><p>. Can I avoid this? - Stack Overflow

programmeradmin2浏览0评论

I am using TinyMCE (/) in a .NET page. Whenever I load a text

myTMCE.value=mycontent;

I can see that my text gets wrapped in <p></p>. This is not desirable for me, so I am trying to avoid it. Trying to initialize in

        <script>
            tinyMCE.init({
                force_p_newlines: true
            })

        </script>

did not work. Any idea? Thanks in advance, m.

I am using TinyMCE (http://tinymce.moxiecode./) in a .NET page. Whenever I load a text

myTMCE.value=mycontent;

I can see that my text gets wrapped in <p></p>. This is not desirable for me, so I am trying to avoid it. Trying to initialize in

        <script>
            tinyMCE.init({
                force_p_newlines: true
            })

        </script>

did not work. Any idea? Thanks in advance, m.

Share Improve this question edited May 6, 2009 at 17:48 Dan Lew 87.4k33 gold badges184 silver badges176 bronze badges asked Apr 29, 2009 at 10:21 pomarcpomarc 2,2244 gold badges25 silver badges30 bronze badges
Add a ment  | 

4 Answers 4

Reset to default 9

You need to to do this :

<script>
    tinyMCE.init({
        forced_root_block: false,
        //some other options here
    })
</script>

By default TinyMCE sets as a root block. By setting this property to false you remove any wrapper for the text. The below text is from TinyMCE documentation:

This option enables you to make sure that any non block elements or text nodes are wrapped in block elements. For example something will result in output like:

something

This option is enabled by default as of 3.0a1.

If you set this option to false it will never produce P tags on enter or automatically it will instead produce BR elements and Shift+Enter will produce a P.

Note that not using P elements as root block can severely cripple the functionality of the editor.

http://www.tinymce./wiki.php/Configuration:forced_root_block

See this thread and the answer in TinyMCE forum. force_p_newline is a gecko only option (ie FF).

You could strip <p> tags after the fact using .NET, or alternatively, just use a plain <textarea> field for data entry if that suits what you're trying to do.

TinyMCE adds a whole load of tags to the text - its design goal is to create valid html from arbitrary input (including html input). If you want control over the generated html code, you're better off using another editor.

发布评论

评论列表(0)

  1. 暂无评论