JasonWoof Got questions, comments, patches, etc.? Contact Jason Woofenden
vanilla ckeditor-3.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">\r
26         editor = CKEDITOR.appendTo( 'editor' );\r
27         editor.setData( html );\r
28 \r
29         // This sample may break here if the ckeditor_basic.js is used. In such case, the following code should be used instead:\r
30         /*\r
31         if ( editor.setData )\r
32         editor.setData( html );\r
33         else\r
34         CKEDITOR.on( 'loaded', function()\r
35         {\r
36         editor.setData( html );\r
37         });\r
38         */\r
39 }\r
40 \r
41 function removeEditor()\r
42 {\r
43         if ( !editor )\r
44                 return;\r
45 \r
46         // Retrieve the editor contents. In an Ajax application, this data would be\r
47         // sent to the server or used in any other way.\r
48         document.getElementById( 'editorcontents' ).innerHTML = editor.getData();\r
49         document.getElementById( 'contents' ).style.display = '';\r
50 \r
51         // Destroy the editor.\r
52         editor.destroy();\r
53         editor = null;\r
54 }\r
55 \r
56         //]]>\r
57         </script>\r
58 </head>\r
59 <body>\r
60         <h1>\r
61                 CKEditor Sample\r
62         </h1>\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>\r
74                 <input onclick="createEditor();" type="button" value="Create Editor" />\r
75                 <input onclick="removeEditor();" type="button" value="Remove Editor" />\r
76         </p>\r
77         <!-- This div will hold the editor. -->\r
78         <div id="editor">\r
79         </div>\r
80         <div id="contents" style="display: none">\r
81                 <p>\r
82                         Edited Contents:</p>\r
83                 <!-- This div will be used to display the editor contents. -->\r
84                 <div id="editorcontents">\r
85                 </div>\r
86         </div>\r
87         <div id="footer">\r
88                 <hr />\r
89                 <p>\r
90                         CKEditor - The text editor for Internet - <a href="http://ckeditor.com/">http://ckeditor.com</a>\r
91                 </p>\r
92                 <p id="copy">\r
93                         Copyright &copy; 2003-2010, <a href="http://cksource.com/">CKSource</a> - Frederico\r
94                         Knabben. All rights reserved.\r
95                 </p>\r
96         </div>\r
97 </body>\r
98 </html>\r