我想让 ckeditor 在页面上只读,并且只读。我该怎么做呢?我试图修改下面的代码来做到这一点,但我似乎无法弄清楚。
我使编辑器具有切换只读模式,该模式加载为非只读模式。(这不是我想要的,但这是我得到的最接近的)这是我拥有的代码:
window.onload = function () {
CKEDITOR.replace('textBox', );
}
var editor;
// The instanceReady event is fired, when an instance of CKEditor has finished
// its initialization.
CKEDITOR.on('instanceReady', function (ev) {
editor = ev.editor;
// Show this "on" button.
document.getElementById('readOnlyOn').style.display = '';
// Event fired when the readOnly property changes.
editor.on('readOnly', function () {
document.getElementById('readOnlyOn').style.display = this.readOnly ? 'none' : '';
document.getElementById('readOnlyOff').style.display = this.readOnly ? '' : 'none';
});
});
function toggleReadOnly(isReadOnly) {
// Change the read-only state of the editor.
// http://docs.cksource.com/ckeditor_api/symbols/CKEDITOR.editor.html#setReadOnly
editor.setReadOnly(isReadOnly);
}
和html:
<p>
<textarea class="ckeditor" id="editor1" name="editor1" style="height:400px;width:900px">${alert.html}</textarea>
</p>
<p>
<input id="readOnlyOn" onclick="toggleReadOnly();" type="button" value="Make it read-only"
style="display:none" />
<input id="readOnlyOff" onclick="toggleReadOnly( false );" type="button"
value="Make it editable again" style="display:none" />
</p>