← Gesamte Dokumentation

HTML-Inhalt setzen und abrufen

Diese Anleitung behandelt die üblichen Wege, HTML-Inhalt in RichTextEditor zu setzen und abzurufen.

1. Inhalt mit JavaScript abrufen

<!-- 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. Inhalt automatisch per POST eines HTML-<form> abrufen

Ersetzt RichTextEditor ein <textarea>-Element innerhalb eines <form>, ahmt RichTextEditor beim Absenden des Formulars das Verhalten der ursprünglichen <textarea> nach. Der Inhalt des Editors wird also einfach zusammen mit den anderen Formularelementen gesendet, mit dem Attribut name der ursprünglichen <textarea> als Schlüssel.

<!-- Create a new DIV element with all of the content that we want inside the Editor -->
<textarea id="inp_editor1">&lt;p&gt;Initial Document Content&lt;/p&gt;</textarea>
//Initialize Richtexteditor for the matched element
var editor1 = new RichTextEditor("#inp_editor1");