Ticket #14613: index.html

File index.html, 1.1 KB (added by Brian, 9 years ago)

Simple html to async load ckeditor, inject and destroy it

Line 
1<html>
2<body>
3<script>
4function toggle() {
5  var editor = !!window['CKEDITOR'] && CKEDITOR.instances.editor;
6  if (!editor) {
7    loadScript('ckeditor/ckeditor.js', function() {
8      CKEDITOR.config.height = 150;
9      CKEDITOR.config.width = 'auto';
10      CKEDITOR.replace( 'editor' )
11      setTimeout(function() {
12         CKEDITOR.instances.editor.destroy();
13      },0);
14    });
15  }
16}
17function loadScript(url, callback){
18
19    var script = document.createElement("script")
20    script.type = "text/javascript";
21
22    if (script.readyState){  //IE
23        script.onreadystatechange = function(){
24            if (script.readyState == "loaded" ||
25                    script.readyState == "complete"){
26                script.onreadystatechange = null;
27                callback();
28            }
29        };
30    } else {  //Others
31        script.onload = function(){
32            callback();
33        };
34    }
35
36    script.src = url;
37    document.getElementsByTagName("head")[0].appendChild(script);
38}
39</script>
40<button type="button" onclick="toggle()">Load/Destory</button>
41<div id="editor"></div>
42</body>
43</html>
© 2003 – 2022, CKSource sp. z o.o. sp.k. All rights reserved. | Terms of use | Privacy policy