replacebycode.html 3.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  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 &mdash; CKEditor Sample</title>
  9. <meta content="text/html; charset=utf-8" http-equiv="content-type" />
  10. <script type="text/javascript" src="../ckeditor.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. <h1 class="samples">
  16. CKEditor Sample &mdash; Replace Textarea Elements Using JavaScript Code
  17. </h1>
  18. <div class="description">
  19. <p>
  20. This sample shows how to automatically replace all <code>&lt;textarea&gt;</code> elements
  21. with a CKEditor instance by using a JavaScript call.
  22. </p>
  23. <p>
  24. To replace a <code>&lt;textarea&gt;</code> element, place the following call at any point
  25. after the <code>&lt;textarea&gt;</code> element or inside a <code>&lt;script&gt;</code> element located
  26. in the <code>&lt;head&gt;</code> section of the page, in a <code>window.onload</code> event handler:
  27. </p>
  28. <pre class="samples">CKEDITOR.replace( '<em>textarea_id</em>' );</pre>
  29. <p>
  30. Note that <code><em>textarea_id</em></code> in the code above is the <code>id</code> attribute of
  31. the <code>&lt;textarea&gt;</code> element to be replaced.
  32. </p>
  33. </div>
  34. <!-- This <div> holds alert messages to be display in the sample page. -->
  35. <div id="alerts">
  36. <noscript>
  37. <p>
  38. <strong>CKEditor requires JavaScript to run</strong>. In a browser with no JavaScript
  39. support, like yours, you should still see the contents (HTML data) and you should
  40. be able to edit it normally, without a rich editor interface.
  41. </p>
  42. </noscript>
  43. </div>
  44. <form action="sample_posteddata.php" method="post">
  45. <p>
  46. <label for="editor1">
  47. Editor 1:</label>
  48. <textarea cols="80" id="editor1" name="editor1" rows="10">&lt;p&gt;This is some &lt;strong&gt;sample text&lt;/strong&gt;. You are using &lt;a href="http://ckeditor.com/"&gt;CKEditor&lt;/a&gt;.&lt;/p&gt;</textarea>
  49. <script type="text/javascript">
  50. //<![CDATA[
  51. // This call can be placed at any point after the
  52. // <textarea>, or inside a <head><script> in a
  53. // window.onload event handler.
  54. // Replace the <textarea id="editor"> with an CKEditor
  55. // instance, using default configurations.
  56. CKEDITOR.replace( 'editor1' );
  57. //]]>
  58. </script>
  59. </p>
  60. <p>
  61. <label for="editor2">
  62. Editor 2:</label>
  63. <textarea cols="80" id="editor2" name="editor2" rows="10">&lt;p&gt;This is some &lt;strong&gt;sample text&lt;/strong&gt;. You are using &lt;a href="http://ckeditor.com/"&gt;CKEditor&lt;/a&gt;.&lt;/p&gt;</textarea>
  64. <script type="text/javascript">
  65. //<![CDATA[
  66. // This call can be placed at any point after the
  67. // <textarea>, or inside a <head><script> in a
  68. // window.onload event handler.
  69. // Replace the <textarea id="editor"> with an CKEditor
  70. // instance, using default configurations.
  71. CKEDITOR.replace( 'editor2' );
  72. //]]>
  73. </script>
  74. </p>
  75. <p>
  76. <input type="submit" value="Submit" />
  77. </p>
  78. </form>
  79. <div id="footer">
  80. <hr />
  81. <p>
  82. CKEditor - The text editor for the Internet - <a class="samples" href="http://ckeditor.com/">http://ckeditor.com</a>
  83. </p>
  84. <p id="copy">
  85. Copyright &copy; 2003-2011, <a class="samples" href="http://cksource.com/">CKSource</a> - Frederico
  86. Knabben. All rights reserved.
  87. </p>
  88. </div>
  89. </body>
  90. </html>