<html> <head> <meta charset="utf-8"> <title>A Simple Page with CKEditor</title> <!-- Make sure the path to CKEditor is correct. --> <script src="../ckeditor.js"/> </meta></head> <body> <form> <textarea name="editor1" id="editor1" rows="10" cols="80"> This is my textarea to be replaced with CKEditor. </textarea> <script> // Replace the <textarea id="editor1"> with a CKEditor // instance, using default configuration. CKEDITOR.replace( 'editor1' ); </script> </form> </body> </html>
var data = editor.getSnapshot(); editor.loadSnapshot( data );
八、设置光标位置
1 2 3 4 5 6 7 8
editor.focus(); var selection = editor.getSelection(); var range = selection.getRanges()[0]; var pCon = range.startContainer.getAscendant({p:2},true); //getAscendant('p',true);
var newRange = new CKEDITOR.dom.range(range.document); newRange.moveToPosition(pCon, CKEDITOR.POSITION_BEFORE_START); newRange.select();