JasonWoof Got questions, comments, patches, etc.? Contact Jason Woofenden
vanilla ckeditor-3.2.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-2010, 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 - 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>\r
50                 CKEditor Sample\r
51         </h1>\r
52         <!-- This <div> holds alert messages to be display in the sample page. -->\r
53         <div id="alerts">\r
54                 <noscript>\r
55                         <p>\r
56                                 <strong>CKEditor requires JavaScript to run</strong>. In a browser with no JavaScript\r
57                                 support, like yours, you should still see the contents (HTML data) and you should\r
58                                 be able to edit it normally, without a rich editor interface.\r
59                         </p>\r
60                 </noscript>\r
61         </div>\r
62         <p>\r
63                 <input onclick="createEditor();" type="button" value="Create Editor" />\r
64                 <input onclick="removeEditor();" type="button" value="Remove Editor" />\r
65         </p>\r
66         <!-- This div will hold the editor. -->\r
67         <div id="editor">\r
68         </div>\r
69         <div id="contents" style="display: none">\r
70                 <p>\r
71                         Edited Contents:</p>\r
72                 <!-- This div will be used to display the editor contents. -->\r
73                 <div id="editorcontents">\r
74                 </div>\r
75         </div>\r
76         <div id="footer">\r
77                 <hr />\r
78                 <p>\r
79                         CKEditor - The text editor for Internet - <a href="http://ckeditor.com/">http://ckeditor.com</a>\r
80                 </p>\r
81                 <p id="copy">\r
82                         Copyright &copy; 2003-2010, <a href="http://cksource.com/">CKSource</a> - Frederico\r
83                         Knabben. All rights reserved.\r
84                 </p>\r
85         </div>\r
86 </body>\r
87 </html>\r