1 | <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> |
---|
2 | <!-- |
---|
3 | * FCKeditor - The text editor for Internet - http://www.fckeditor.net |
---|
4 | * Copyright (C) 2003-2007 Frederico Caldeira Knabben |
---|
5 | * |
---|
6 | * == BEGIN LICENSE == |
---|
7 | * |
---|
8 | * Licensed under the terms of any of the following licenses at your |
---|
9 | * choice: |
---|
10 | * |
---|
11 | * - GNU General Public License Version 2 or later (the "GPL") |
---|
12 | * http://www.gnu.org/licenses/gpl.html |
---|
13 | * |
---|
14 | * - GNU Lesser General Public License Version 2.1 or later (the "LGPL") |
---|
15 | * http://www.gnu.org/licenses/lgpl.html |
---|
16 | * |
---|
17 | * - Mozilla Public License Version 1.1 or later (the "MPL") |
---|
18 | * http://www.mozilla.org/MPL/MPL-1.1.html |
---|
19 | * |
---|
20 | * == END LICENSE == |
---|
21 | * |
---|
22 | * Sample page. |
---|
23 | --> |
---|
24 | <html xmlns="http://www.w3.org/1999/xhtml"> |
---|
25 | <head> |
---|
26 | <title>FCKeditor - Sample</title> |
---|
27 | <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> |
---|
28 | <meta name="robots" content="noindex, nofollow" /> |
---|
29 | <link href="../sample.css" rel="stylesheet" type="text/css" /> |
---|
30 | <script type="text/javascript" src="../../fckeditor.js"></script> |
---|
31 | <script type="text/javascript"> |
---|
32 | |
---|
33 | // FCKeditor_OnComplete is a special function that is called when an editor |
---|
34 | // instance is loaded ad available to the API. It must be named exactly in |
---|
35 | // this way. |
---|
36 | function FCKeditor_OnComplete( editorInstance ) |
---|
37 | { |
---|
38 | // Show the editor name and description in the browser status bar. |
---|
39 | document.getElementById('eMessage').innerHTML = 'Instance "' + editorInstance.Name + '" loaded - ' + editorInstance.Description ; |
---|
40 | } |
---|
41 | |
---|
42 | function SetContents() |
---|
43 | { |
---|
44 | // Get the editor instance that we want to interact with. |
---|
45 | var oEditor = FCKeditorAPI.GetInstance('FCKeditor1') ; |
---|
46 | |
---|
47 | // Set the editor contents (replace the actual one). |
---|
48 | |
---|
49 | oEditor.SetHTML( document.getElementById('ble').value,true ) ; |
---|
50 | } |
---|
51 | |
---|
52 | function GetContents() |
---|
53 | { |
---|
54 | // Get the editor instance that we want to interact with. |
---|
55 | var oEditor = FCKeditorAPI.GetInstance('FCKeditor1') ; |
---|
56 | |
---|
57 | // Get the editor contents in XHTML. |
---|
58 | alert( oEditor.GetXHTML( true ) ) ; // "true" means you want it formatted. |
---|
59 | } |
---|
60 | |
---|
61 | function GetInnerHTML() |
---|
62 | { |
---|
63 | // Get the editor instance that we want to interact with. |
---|
64 | var oEditor = FCKeditorAPI.GetInstance('FCKeditor1') ; |
---|
65 | |
---|
66 | alert( oEditor.EditorDocument.body.innerHTML ) ; |
---|
67 | } |
---|
68 | |
---|
69 | function CheckIsDirty() |
---|
70 | { |
---|
71 | // Get the editor instance that we want to interact with. |
---|
72 | var oEditor = FCKeditorAPI.GetInstance('FCKeditor1') ; |
---|
73 | alert( oEditor.IsDirty() ) ; |
---|
74 | } |
---|
75 | |
---|
76 | function ResetIsDirty() |
---|
77 | { |
---|
78 | // Get the editor instance that we want to interact with. |
---|
79 | var oEditor = FCKeditorAPI.GetInstance('FCKeditor1') ; |
---|
80 | oEditor.ResetIsDirty() ; |
---|
81 | alert( 'The "IsDirty" status has been reset' ) ; |
---|
82 | } |
---|
83 | |
---|
84 | </script> |
---|
85 | </head> |
---|
86 | <body> |
---|
87 | <h1> |
---|
88 | FCKeditor - JavaScript - Sample 8 |
---|
89 | </h1> |
---|
90 | <div> |
---|
91 | This sample shows how to use the FCKeditor JavaScript API to interact with the editor |
---|
92 | at runtime. |
---|
93 | </div> |
---|
94 | <hr /> |
---|
95 | <form action="sampleposteddata.asp" method="post" target="_blank"> |
---|
96 | <script type="text/javascript"> |
---|
97 | <!-- |
---|
98 | // Automatically calculates the editor base path based on the _samples directory. |
---|
99 | // This is usefull only for these samples. A real application should use something like this: |
---|
100 | // oFCKeditor.BasePath = '/fckeditor/' ; // '/fckeditor/' is the default value. |
---|
101 | var sBasePath = document.location.pathname.substring(0,document.location.pathname.lastIndexOf('_samples')) ; |
---|
102 | |
---|
103 | var oFCKeditor = new FCKeditor( 'FCKeditor1' ) ; |
---|
104 | oFCKeditor.BasePath = sBasePath ; |
---|
105 | oFCKeditor.Value = 'This is some <strong>sample text</strong>. You are using <a href="http://www.fckeditor.net/">FCKeditor</a>.' ; |
---|
106 | oFCKeditor.Create() ; |
---|
107 | //--> |
---|
108 | </script> |
---|
109 | <br /> |
---|
110 | <input type="submit" value="Submit" /> |
---|
111 | </form> |
---|
112 | <div> |
---|
113 | |
---|
114 | </div> |
---|
115 | <hr /> |
---|
116 | <div id="eMessage"> |
---|
117 | |
---|
118 | </div> |
---|
119 | <div> |
---|
120 | |
---|
121 | </div> |
---|
122 | |
---|
123 | <textarea type="text"style='width:400px;height:100px' id='ble' ><table> |
---|
124 | <tbody> |
---|
125 | <tr> |
---|
126 | <td>IsDirty will read incorrectly for this page.</td> |
---|
127 | </tr> |
---|
128 | </tbody> |
---|
129 | </table></textarea> |
---|
130 | <div id="eButtons"> |
---|
131 | <input type="button" value="Set Editor Contents" onclick="SetContents();" /> |
---|
132 | <input type="button" value="Get Editor Contents (XHTML)" onclick="GetContents();" /> |
---|
133 | |
---|
134 | <input type="button" value="Get innerHTML" onclick="GetInnerHTML();" /> |
---|
135 | |
---|
136 | <input type="button" value="Check IsDirty()" onclick="CheckIsDirty();" /> |
---|
137 | <input type="button" value="Reset IsDirty()" onclick="ResetIsDirty();" /> |
---|
138 | </div> |
---|
139 | </body> |
---|
140 | </html> |
---|