How to find and replace text in CKEditor using Javascript?

房东的猫 提交于 2019-12-17 19:47:41

问题


How could I find and replace text in CKEditor using Javascript? Thanks for your suggestion!


回答1:


try this

editor = CKEDITOR.instances.fck; //fck is just my instance name you will need to replace that with yours

var edata = editor.getData();

var replaced_text = edata.replace("idontwant", "iwant this instead"); // you could also use a regex in the replace 

editor.setData(replaced_text);

you may want to put that in a blur event or soemthing



来源:https://stackoverflow.com/questions/5635118/how-to-find-and-replace-text-in-ckeditor-using-javascript

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!