1 | <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> |
---|
2 | <!-- |
---|
3 | Copyright (c) 2003-2011, CKSource - Frederico Knabben. All rights reserved. |
---|
4 | For licensing, see LICENSE.html or http://ckeditor.com/license |
---|
5 | --> |
---|
6 | <html xmlns="http://www.w3.org/1999/xhtml"> |
---|
7 | <head> |
---|
8 | <title>Replace Textarea by Code — CKEditor Sample</title> |
---|
9 | <meta content="text/html; charset=utf-8" http-equiv="content-type" /> |
---|
10 | <script type="text/javascript" src="../ckeditor_source.js"></script> |
---|
11 | <script src="sample.js" type="text/javascript"></script> |
---|
12 | <link href="sample.css" rel="stylesheet" type="text/css" /> |
---|
13 | </head> |
---|
14 | <body> |
---|
15 | |
---|
16 | <form action="sample_posteddata.php" method="post" name="testform"> |
---|
17 | <p> |
---|
18 | <label for="editor1"> |
---|
19 | Editor 1:</label> |
---|
20 | <textarea cols="80" id="editor1" name="editor1" rows="10"> |
---|
21 | <p>This is some <strong>sample text</strong>. You are using <a href="http://ckeditor.com/">CKEditor</a>.</p> |
---|
22 | <img id="aaa" alt="" src="http://a.cksource.com/c/1/inc/img/demo-little-red.jpg" style="width: 102px; height: 77px;" /> |
---|
23 | </textarea> |
---|
24 | |
---|
25 | <script type="text/javascript"> |
---|
26 | function doSth(editor){ |
---|
27 | //var editor = getEditor(); |
---|
28 | editor.document.$.execCommand('RespectVisibilityInDesign', true, true); |
---|
29 | var imgArray = window.document.getElementsByTagName('iframe')[0].contentWindow.document.images; |
---|
30 | //console.log(imgArray.length); |
---|
31 | for (var i = 0; i < imgArray.length; i++) { |
---|
32 | var obj = editor.document.getById(imgArray[i].id); |
---|
33 | obj.hide(); |
---|
34 | } |
---|
35 | } |
---|
36 | |
---|
37 | var editor = CKEDITOR.replace( 'editor1' ,{}); |
---|
38 | |
---|
39 | editor.on('mode', function(evt){ |
---|
40 | if(evt.editor.document) |
---|
41 | evt.editor.document.$.execCommand('RespectVisibilityInDesign', true, true); |
---|
42 | }); |
---|
43 | |
---|
44 | |
---|
45 | </script> |
---|
46 | </p> |
---|
47 | <p> |
---|
48 | <input type="button" onclick="doSth(editor);return false;" value="doSth" /> |
---|
49 | </p> |
---|
50 | </form> |
---|
51 | <div id="footer"> |
---|
52 | <hr /> |
---|
53 | <p> |
---|
54 | CKEditor - The text editor for the Internet - <a class="samples" href="http://ckeditor.com/">http://ckeditor.com</a> |
---|
55 | </p> |
---|
56 | <p id="copy"> |
---|
57 | Copyright © 2003-2011, <a class="samples" href="http://cksource.com/">CKSource</a> - Frederico |
---|
58 | Knabben. All rights reserved. |
---|
59 | </p> |
---|
60 | </div> |
---|
61 | </body> |
---|
62 | </html> |
---|