1 | <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> |
---|
2 | <html xmlns="http://www.w3.org/1999/xhtml"> |
---|
3 | <head> |
---|
4 | <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> |
---|
5 | <title>Untitled Document</title> |
---|
6 | |
---|
7 | <script type="text/javascript" src="ckeditor/ckeditor.js"></script> |
---|
8 | </head> |
---|
9 | |
---|
10 | <body> |
---|
11 | |
---|
12 | <textarea name="fullstory" cols="60" rows="20" class="body_text"></textarea> |
---|
13 | <!-- START CKeditor javascript --> |
---|
14 | <script type="text/javascript"> |
---|
15 | <!-- START replaces textarea and loads simple toolbar--> |
---|
16 | CKEDITOR.replace( 'fullstory', |
---|
17 | { |
---|
18 | toolbarCanCollapse : false, |
---|
19 | contentsCSS : 'style.css', |
---|
20 | resize_enabled : false, |
---|
21 | skin : 'office2003', |
---|
22 | maxlength : '3000', |
---|
23 | charcount_limit: '3000' |
---|
24 | }); |
---|
25 | <!-- END replaces textarea and loads simple toolbar--> |
---|
26 | |
---|
27 | <!-- START Update the counter with text length of editor HTML output--> |
---|
28 | editor = CKEDITOR.instances.fullstory; |
---|
29 | editor.on( 'key', function( evt ){ |
---|
30 | textCounter( { value : evt.editor.getData() },this.form.remLen2, 3000 ); |
---|
31 | }, editor.element.$ ); |
---|
32 | <!-- END Update the counter with text length of editor HTML output--> |
---|
33 | |
---|
34 | <!-- START Whether content has exceeded the maximum characters--> |
---|
35 | var locked; |
---|
36 | editor.on( 'key', function( evt ){ |
---|
37 | var currentLength = editor.getData().length, |
---|
38 | maximumLength = 3000; |
---|
39 | if( currentLength >= maximumLength ) { |
---|
40 | if ( !locked ) { |
---|
41 | // Record the last legal content. |
---|
42 | editor.fire( 'saveSnapshot' ), locked = 1; |
---|
43 | // Cancel the keystroke. |
---|
44 | evt.cancel(); |
---|
45 | } else { |
---|
46 | // Check after this key has effected. |
---|
47 | setTimeout( function() { // Rollback the illegal one. |
---|
48 | if( editor.getData().length > maximumLength ) { |
---|
49 | editor.execCommand( 'undo' ); |
---|
50 | } else { |
---|
51 | locked = 0; |
---|
52 | } |
---|
53 | }, 0 ); |
---|
54 | } |
---|
55 | } |
---|
56 | } ); |
---|
57 | <!-- END Whether content has exceeded the maximum characters--> |
---|
58 | </script> |
---|
59 | <!-- END CKeditor JavaScript --> |
---|
60 | </body> |
---|
61 | </html> |
---|