Définir et lire le contenu HTML
Ce guide présente les façons courantes de définir et de récupérer le contenu HTML dans RichTextEditor.
1. Lire le contenu avec JavaScript
<!-- Create a new DIV element with all of the content that we want inside the Editor -->
<div id="div_editor1"></div> //Initialize Richtexteditor for the matched element
var editor1 = new RichTextEditor("#div_editor1");
//Setting Content with Javascript
editor1.setHTMLCode("Use inline HTML or setHTMLCode to set the default content.");<!-- Retrieve the HTML from the editor by using the editor.getHTMLCode() method. -->
<button onclick="alert(editor1.getHTMLCode())">Show Html Code</button>2. Récupérer automatiquement le contenu avec un POST de <form> HTML
Quand RichTextEditor remplace un élément <textarea> dans un <form>, RichTextEditor reproduit le comportement du <textarea> d’origine lors de l’envoi du formulaire. Le contenu de l’éditeur est donc simplement envoyé avec les autres éléments du formulaire, en utilisant comme clé l’attribut name du <textarea> d’origine.
<!-- Create a new DIV element with all of the content that we want inside the Editor -->
<textarea id="inp_editor1"><p>Initial Document Content</p></textarea>//Initialize Richtexteditor for the matched element
var editor1 = new RichTextEditor("#inp_editor1");