1 <!DOCTYPE html PUBLIC
"-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
3 Copyright (c) 2003-2011, CKSource - Frederico Knabben. All rights reserved.
4 For licensing, see LICENSE.html or http://ckeditor.com/license
6 <html xmlns=
"http://www.w3.org/1999/xhtml">
8 <title>Ajax
— CKEditor Sample
</title>
9 <meta content=
"text/html; charset=utf-8" http-equiv=
"content-type" />
10 <script type=
"text/javascript" src=
"../ckeditor.js"></script>
11 <script src=
"sample.js" type=
"text/javascript"></script>
12 <link href=
"sample.css" rel=
"stylesheet" type=
"text/css" />
13 <script type=
"text/javascript">
18 function createEditor()
23 var html
= document
.getElementById( 'editorcontents' ).innerHTML
;
25 // Create a new editor inside the <div id="editor">, setting its value to html
27 editor
= CKEDITOR
.appendTo( 'editor', config
, html
);
30 function removeEditor()
35 // Retrieve the editor contents. In an Ajax application, this data would be
36 // sent to the server or used in any other way.
37 document
.getElementById( 'editorcontents' ).innerHTML
= editor
.getData();
38 document
.getElementById( 'contents' ).style
.display
= '';
40 // Destroy the editor.
50 CKEditor Sample
— Create and Destroy Editor Instances for Ajax Applications
52 <div class=
"description">
54 This sample shows how to create and destroy CKEditor instances on the fly. After the removal of CKEditor the content created inside the editing
55 area will be displayed in a
<code><div
></code> element.
58 For details of how to create this setup check the source code of this sample page
59 for JavaScript code responsible for the creation and destruction of a CKEditor instance.
63 <!-- This <div> holds alert messages to be display in the sample page. -->
67 <strong>CKEditor requires JavaScript to run
</strong>. In a browser with no JavaScript
68 support, like yours, you should still see the contents (HTML data) and you should
69 be able to edit it normally, without a rich editor interface.
73 <p>Click the buttons to create and remove a CKEditor instance.
</p>
75 <input onclick=
"createEditor();" type=
"button" value=
"Create Editor" />
76 <input onclick=
"removeEditor();" type=
"button" value=
"Remove Editor" />
78 <!-- This div will hold the editor. -->
81 <div id=
"contents" style=
"display: none">
84 <!-- This div will be used to display the editor contents. -->
85 <div id=
"editorcontents">
91 CKEditor - The text editor for the Internet -
<a class=
"samples" href=
"http://ckeditor.com/">http://ckeditor.com
</a>
94 Copyright
© 2003-
2011,
<a class=
"samples" href=
"http://cksource.com/">CKSource
</a> - Frederico
95 Knabben. All rights reserved.