How to extract HTML content from TinyMCE Editor

后端 未结 4 923
情歌与酒
情歌与酒 2020-12-31 03:02

I\'m a beginner on Javascript/TinyMCE and I try to understand how is it possible to get the HTML content from the editor, and show it with a simple alert() function.

<
4条回答
  •  灰色年华
    2020-12-31 03:19

    I don't know why it doesn't work

    It's not working because

    console.debug(tinyMCE.activeEditor.getContent());
    
    tinymce.activeEditor.getContent();
    

    these statements are not being executed.

    Try to follow this FIDDLE ....

    tinyMCE.init({
            // General options
            mode : "specific_textareas",
            editor_selector : "mceEditor"
    });
    

    Function for getting content ....

    function get_editor_content() {
      // Get the HTML contents of the currently active editor
      console.debug(tinyMCE.activeEditor.getContent());
      //method1 getting the content of the active editor
      alert(tinyMCE.activeEditor.getContent());
      //method2 getting the content by id of a particular textarea
      alert(tinyMCE.get('myarea1').getContent());
    }
    

    Get the content of editor on button click ...

     
    

提交回复
热议问题