Ticket #8725: ajax.html

File ajax.html, 3.4 KB (added by mars, 7 years ago)

appendTo can not work

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