| 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-2013, CKSource - Frederico Knabben. All rights reserved. |
|---|
| 4 | For licensing, see LICENSE.html or http://ckeditor.com/license |
|---|
| 5 | --> |
|---|
| 6 | <html> |
|---|
| 7 | <head> |
|---|
| 8 | <title>Replace Textarea by Code — CKEditor Sample</title> |
|---|
| 9 | <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> |
|---|
| 10 | <script src="//ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script> |
|---|
| 11 | <script src="../ckeditor.js" ></script> |
|---|
| 12 | <link href="sample.css" rel="stylesheet"> |
|---|
| 13 | </head> |
|---|
| 14 | <body> |
|---|
| 15 | <h1 class="samples"> |
|---|
| 16 | <a href="index.html">CKEditor Samples</a> » Replace Textarea Elements Using JavaScript Code |
|---|
| 17 | </h1> |
|---|
| 18 | <form action="sample_posteddata.php" method="post"> <!-- accept-charset="windows-1252" --> |
|---|
| 19 | <div class="description"> |
|---|
| 20 | <p> |
|---|
| 21 | This editor is using an <code><iframe></code> element-based editing area, provided by the <strong>Wysiwygarea</strong> plugin. |
|---|
| 22 | </p> |
|---|
| 23 | <pre class="samples"> |
|---|
| 24 | |
|---|
| 25 | CKEDITOR.replace( '<em>textarea_id</em>' ) |
|---|
| 26 | </pre> |
|---|
| 27 | </div> |
|---|
| 28 | |
|---|
| 29 | <div id="editor1" autocomplete="off" autocorrect="off" role="group" aria-label="Rich Text Editor - type your response."></div> |
|---|
| 30 | <script> |
|---|
| 31 | CKEDITOR.on('instanceReady', function (ev) { |
|---|
| 32 | var doc = editor.document.$; |
|---|
| 33 | var win = editor.document.getWindow().$; |
|---|
| 34 | |
|---|
| 35 | var s = '<style>body.cke_editable {' + |
|---|
| 36 | 'position: absolute;' + |
|---|
| 37 | 'overflow: auto;' + |
|---|
| 38 | 'top: .3em;' + |
|---|
| 39 | 'bottom: .3em;' + |
|---|
| 40 | 'left: .3em;' + |
|---|
| 41 | 'right: .3em;' + |
|---|
| 42 | '}</style>'; |
|---|
| 43 | |
|---|
| 44 | if(doc == document){ |
|---|
| 45 | console.log('*** Inline'); |
|---|
| 46 | $('head').append(s); |
|---|
| 47 | }else{ |
|---|
| 48 | console.log('*** iFrame'); |
|---|
| 49 | $('.cke_wysiwyg_frame').contents().find('head').append(s); |
|---|
| 50 | } |
|---|
| 51 | }); |
|---|
| 52 | |
|---|
| 53 | var editor = CKEDITOR.appendTo('editor1'); |
|---|
| 54 | |
|---|
| 55 | </script> |
|---|
| 56 | <p> |
|---|
| 57 | <input type="submit" value="Submit"> |
|---|
| 58 | </p> |
|---|
| 59 | </form> |
|---|
| 60 | <div id="footer"> |
|---|
| 61 | <hr> |
|---|
| 62 | <p> |
|---|
| 63 | CKEditor - The text editor for the Internet - <a class="samples" href="http://ckeditor.com/">http://ckeditor.com</a> |
|---|
| 64 | </p> |
|---|
| 65 | <p id="copy"> |
|---|
| 66 | Copyright © 2003-2013, <a class="samples" href="http://cksource.com/">CKSource</a> - Frederico |
|---|
| 67 | Knabben. All rights reserved. |
|---|
| 68 | </p> |
|---|
| 69 | </div> |
|---|
| 70 | </body> |
|---|
| 71 | </html> |
|---|