JasonWoof Got questions, comments, patches, etc.? Contact Jason Woofenden
d2ce3bd5cfe3607843e4dac1f8a0e9c2e06811ff
[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-2009, 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>Sample - CKEditor</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 id="headscript" 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         <!-- This <fieldset> holds the HTML that you will usually find in your\r
74              pages. -->\r
75         <p>\r
76                         <input onclick="createEditor();" type="button" value="Create Editor"/>\r
77                         <input onclick="removeEditor();" type="button" value="Remove Editor"/>\r
78                 </p>\r
79                 <div id="editor">\r
80                 </div>\r
81                 <div id="contents" style="display: none">\r
82                         <p>Edited Contents:</p>\r
83                         <div id="editorcontents"/>\r
84                 </div>\r
85         <div id="footer">\r
86                 <hr/>\r
87                 <p>\r
88                         CKEditor - The text editor for Internet - <a href="http://ckeditor.com/" shape="rect">http://ckeditor.com</a>\r
89                 </p>\r
90                 <p id="copy">\r
91                         Copyright © 2003-2009, <a href="http://cksource.com/" shape="rect">CKSource</a> - Frederico Knabben. All rights reserved.\r
92                 </p>\r
93         </div>\r
94 </body>\r
95 </html>\r