JasonWoof Got questions, comments, patches, etc.? Contact Jason Woofenden
vanilla ckeditor-3.5.1
[ckeditor.git] / _samples / ajax.html
1 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">\r
2 <!--\r
3 Copyright (c) 2003-2011, CKSource - Frederico Knabben. All rights reserved.\r
4 For licensing, see LICENSE.html or http://ckeditor.com/license\r
5 -->\r
6 <html xmlns="http://www.w3.org/1999/xhtml">\r
7 <head>\r
8         <title>Ajax &mdash; CKEditor Sample</title>\r
9         <meta content="text/html; charset=utf-8" http-equiv="content-type" />\r
10         <script type="text/javascript" src="../ckeditor.js"></script>\r
11         <script src="sample.js" type="text/javascript"></script>\r
12         <link href="sample.css" rel="stylesheet" type="text/css" />\r
13         <script type="text/javascript">\r
14         //<![CDATA[\r
15 \r
16 var editor;\r
17 \r
18 function createEditor()\r
19 {\r
20         if ( editor )\r
21                 return;\r
22 \r
23         var html = document.getElementById( 'editorcontents' ).innerHTML;\r
24 \r
25         // Create a new editor inside the <div id="editor">, setting its value to html\r
26         var config = {};\r
27         editor = CKEDITOR.appendTo( 'editor', config, html );\r
28 }\r
29 \r
30 function removeEditor()\r
31 {\r
32         if ( !editor )\r
33                 return;\r
34 \r
35         // Retrieve the editor contents. In an Ajax application, this data would be\r
36         // sent to the server or used in any other way.\r
37         document.getElementById( 'editorcontents' ).innerHTML = editor.getData();\r
38         document.getElementById( 'contents' ).style.display = '';\r
39 \r
40         // Destroy the editor.\r
41         editor.destroy();\r
42         editor = null;\r
43 }\r
44 \r
45         //]]>\r
46         </script>\r
47 </head>\r
48 <body>\r
49         <h1 class="samples">\r
50                 CKEditor Sample &mdash; Create and Destroy Editor Instances for Ajax Applications\r
51         </h1>\r
52         <div class="description">\r
53         <p>\r
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\r
55                 area will be displayed in a <code>&lt;div&gt;</code> element.\r
56         </p>\r
57         <p>\r
58                 For details of how to create this setup check the source code of this sample page\r
59                 for JavaScript code responsible for the creation and destruction of a CKEditor instance.\r
60         </p>\r
61         </div>\r
62 \r
63         <!-- This <div> holds alert messages to be display in the sample page. -->\r
64         <div id="alerts">\r
65                 <noscript>\r
66                         <p>\r
67                                 <strong>CKEditor requires JavaScript to run</strong>. In a browser with no JavaScript\r
68                                 support, like yours, you should still see the contents (HTML data) and you should\r
69                                 be able to edit it normally, without a rich editor interface.\r
70                         </p>\r
71                 </noscript>\r
72         </div>\r
73         <p>Click the buttons to create and remove a CKEditor instance.</p>\r
74         <p>\r
75                 <input onclick="createEditor();" type="button" value="Create Editor" />\r
76                 <input onclick="removeEditor();" type="button" value="Remove Editor" />\r
77         </p>\r
78         <!-- This div will hold the editor. -->\r
79         <div id="editor">\r
80         </div>\r
81         <div id="contents" style="display: none">\r
82                 <p>\r
83                         Edited Contents:</p>\r
84                 <!-- This div will be used to display the editor contents. -->\r
85                 <div id="editorcontents">\r
86                 </div>\r
87         </div>\r
88         <div id="footer">\r
89                 <hr />\r
90                 <p>\r
91                         CKEditor - The text editor for the Internet - <a class="samples" href="http://ckeditor.com/">http://ckeditor.com</a>\r
92                 </p>\r
93                 <p id="copy">\r
94                         Copyright &copy; 2003-2011, <a class="samples" href="http://cksource.com/">CKSource</a> - Frederico\r
95                         Knabben. All rights reserved.\r
96                 </p>\r
97         </div>\r
98 </body>\r
99 </html>\r