How to set the initial text in a TinyMCE textarea?

前端 未结 9 599
慢半拍i
慢半拍i 2021-01-02 07:31

I\'m in a curious situation where I previously had no problem achieving what I\'m looking for. The following code is a part of an HTML page which is to host a TinyMCE rich t

9条回答
  •  北荒
    北荒 (楼主)
    2021-01-02 07:59

    If you don't call tinyMCE's JavaScript function, you may have to deal with browser compatibility issues.

    If you only have one tinymce box on the page, you can just do this:

    tinyMCE.activeEditor.setContent('some');
    

    You can also set a format such as BBCode. Check out the setContent documentation.

    I would have your PHP code echo out the HTML into a JavaScript function and have it called with onload:

    function loadTinyMCE($html) {
        echo "
            
        ";
    }
    

    then

    
    

    If you don't want to use the page onload event, tinymce has an init option called oninit that functions similarly.

    Alternatively, setupcontent_callback gives you direct access to the iframe.

提交回复
热议问题