0

I would like to dynamically modify the CSS in CKEDITOR. I read it is possible via jquery. But I dont know how to tell the jquery, that I want to modify the elements inside the CKEDITOR, not in the whole document.

I tried something like this, but it is not working:

function ok()  {
        $('textarea#editor1').css({
            "color": "Blue",
            "background-color": "orange"
    });

Any ideas? Thanks!

Petr Dušek
  • 627
  • 4
  • 12
  • 26
  • A recent topic on being able to edit in CKEDITOR can be found [here](http://stackoverflow.com/questions/15989223/is-it-possibe-to-modify-this-to-remove-all-img-tags-before-adding-the-new-one/15989303#15989303). Perhaps that will help you. You should make your CKEDITOR instance "editable" and use the [docs](http://docs.cksource.com/ckeditor_api/symbols/CKEDITOR.dom.document.html) to see what DOM commands are available. – Daniel Apr 25 '13 at 13:15

1 Answers1

1

You can use something looking like this

var IframeContent = document.getElementsByClassName('cke_wysiwyg_frame')[0].contentDocument

// Do whatever you want to as if it was your main "document" element
IframeContent.getElementById("...");
IframeContent.getElementsByClassName("...");

Or using jQuery, you could be interested in this solution : How to get the body's content of an iframe in Javascript?

Side note, I don't think you can access to the content of an Iframe from a remote / different domain, so check this if the CKEDITOR isn't on your domain.

Community
  • 1
  • 1
RelevantUsername
  • 1,270
  • 8
  • 14