帝国cms后台,采用的是CKEditor编辑器,外部修改要点:
var selection = CKEDITOR.instances.newstext.getSelection();//获取选择的对象 var text=selection.getSelectedText();//获取选择的文本 var element = CKEDITOR.dom.element.createFromHtml( '<b>'+text+'</b>' ); //处理文本 CKEDITOR.instances.newstext.insertElement( element );//插入元素
判断编辑器是不是加载完成:
function jhcdiy1(){ var waitCKEDITOR = setInterval(function() { if ($("a.cke_button__maximize").length==1) { clearInterval(waitCKEDITOR); diybegin(); } }, 100/*milli*/); }
定制一个按钮:
var html='<a class="cke_button cke_button__diy" title="定制" tabindex="-1" hidefocus="true" role="button" aria-labelledby="cke_78_label" aria-haspopup="false" onblur="this.style.cssText = this.style.cssText;"><span class="cke_button_icon cke_button_diy_icon"> </span></a>'; $("a.cke_button__maximize").after(html); var jhcdiy={ "background-image":"url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADMAAAAaCAMAAAAt3JTmAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAKJQTFRF74lA74k/7og/7og+7oc+7YY87IQ77Yc97IU77IU82W8u2nAw23Ix6qJ653s08Y5H9Pnw6Hw066R94Wgi32cn3d3d22Ei22Eh5Xk68Z9o2Y5k/vz622Af8JNT6urq6ufl2nAv2pFo2nEx6+jm2nEw25Jr64I58IpC8IpB74lB6X842dnZ8YtC9Klz8ItC6oA46oA56oI564M6zWEm21YU////eqMmHwAAAO5JREFUeNqU1NdyAjEMhWHRwbtA6B1SKSkkQfb7v1qOzKx3shfy+Btf+h/JN6bNeGpTTMcb6i9XXylWyz4tdsPPFMPdguy1lHN+jbNkT0HOjvNTFJpzwM45PkehuQS+uUShoYAf0Ihn0qCpBdJ4/FpToKl7GXPGrsB1BZqGkPv3xC+XNRRomsI/35Vzmgo0HVFtOgo0LVE2frfHlgJNT1Tn9BRouqLadBVo2qKym2kr0NyE4f9zboqiQcQ4RWIizbFk+M4cNWh+U6H5SWVpO/pOM9rS22TwnmIweaKX9Tzpf5uvD+T2s48Us737E2AA4VK0g+aX9jkAAAAASUVORK5CYII=')", "background-position":"-5 -5", "background-size":"auto", "margin-left":"10px" }; for(var i in jhcdiy){ $(".cke_button_diy_icon").css(i,jhcdiy[i]); }
此处隐藏922个字。
回复评论可见如何判断浏览器是否支持html5<script>
function
checkhHtml5() {
if
(
typeof
(Worker) !==
"undefined"
) { alert(
"支持HTML5"
); }
else
{ alert(
"不支持HTML5"
); } }
</script>
强制使用js和css
var head = CKEDITOR.instances.Content.document.getHead(); var myscript = CKEDITOR.document.createElement('link', {attributes: {type: 'text/css',rel: 'stylesheet','href': 'mytemp.css'}}); head.append(myscript);