javascript - setting external css to ck editor dynamically in djbrowser -


i embedded ck editor (recent version 4.1) dj browswer. dj browser

and want set external css file (http://mystyle.css) ck editor.

but not want modify or edit config files of ck editor. url of css should set dynamically, on run time , name , url can changed.

what tried invoking following command, did not help.

ckeditor.stylesset.add('mystyle'); .. ckeditor.config.stylesset('mystyle:http://mystyle.css'); 

they key access document object of cke iframe. vomit css link head of document without touching config. example https://stackoverflow.com/a/577002/694325

i assuming use "editor1" name, use whatever have..

var doc = ckeditor.instances.editor1.document.$; // cke doc! var cssid = 'mycss'; if (!doc.getelementbyid(cssid)) {     var head  = doc.getelementsbytagname('head')[0];     var link  = doc.createelement('link');     link.id   = cssid;     link.rel  = 'stylesheet';     link.type = 'text/css';     link.href = 'http://my.little.pony.net/your.css';     link.media = 'all';     head.appendchild(link); } 

or jquery if kind of stuff (https://stackoverflow.com/a/2685661/694325)

var doc = ckeditor.instances.editor1.document.$; // shortcut $("<link/>", {    rel: "stylesheet",    type: "text/css",    href: "http://my.little.pony.net/your.css" }).appendto($(doc).find("head")); 

Comments

Popular posts from this blog

Why does Ruby on Rails generate add a blank line to the end of a file? -

keyboard - Smiles and long press feature in Android -

node.js - Bad Request - node js ajax post -