标签:
ckedit的源码模式下是禁用insertText方法的 ,下面是解决方案
if(CKEDITOR.instances[Itemname].mode==‘wysiwyg‘){ CKEDITOR.instances[Itemname].insertText(TextToInsert); } else{ var input = document.getElementsByClassName(‘cke_source cke_enable_context_menu‘)[0]; input.focus(); if(typeof input.selectionStart != ‘undefined‘) { /* Einfügen des Formatierungscodes */ var start = input.selectionStart; var end = input.selectionEnd; input.value = input.value.substr(0, start) + TextToInsert + input.value.substr(end); /* Anpassen der Cursorposition */ var pos; pos = start+TextToInsert.length; input.selectionStart = pos; input.selectionEnd = pos; } }
标签:
原文地址:http://www.cnblogs.com/zhuwenjun/p/4544301.html