sai*_*can 7 html javascript ckeditor
我试过这些但是一直有一个未定义的函数错误:
CKEDITOR.instances.myEditorID.insertHtml( '<p>This is a new paragraph.</p>' );
CKEDITOR.instances.myEditorID.setData( '<p>This is the editor data.</p>' );
Run Code Online (Sandbox Code Playgroud)
我也尝试了这个但仍未定义函数错误:
CKEDITOR.instances.YOUREDITORID.updateElement();
alert( document.getElementById( 'YOUREDITORID' ).value );
Run Code Online (Sandbox Code Playgroud)
而不是myEditorID,我试过'编辑','editor1','editor2',但仍然不适合我.
提前致谢.
---更新---
这是我的ckeditor文本编辑器的html:
<textarea id="myEditorID" name="myEditor"></textarea>
<script type="text/javascript">
$(function () {
var myEditor = $('#myEditorID');
myEditor.ckeditor({
height: 200,
extraPlugins: 'charcount',
maxLength: 2000,
toolbar: 'TinyBare',
toolbar_TinyBare: [
['Bold','Italic','Underline'],
['Undo','Redo'],['Cut','Copy','Paste'],
['NumberedList','BulletedList','Table'],['CharCount']
]
}).ckeditor().editor.on('key', function(obj) {
if (obj.data.keyCode === 8 || obj.data.keyCode === 46) {
return true;
}
if (myEditor.ckeditor().editor.document.getBody().getText().length >= 2000) {
alert('You have reached the maximum char length');
return false;
}
});
});
</script>
Run Code Online (Sandbox Code Playgroud)
而不是myEditorID,我试过'编辑','editor1','editor2',但仍然不适合我.
您需要查看页面的HTML并查看编辑器的ID字段.它会是这样的
<textarea id="my_editor"></textarea>
Run Code Online (Sandbox Code Playgroud)
那个id属性是需要进入的地方
CKEDITOR.instances.my_editor.insertHtml('<p>This is a new paragraph.</p>');
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
18969 次 |
| 最近记录: |