horst Posted July 9, 2018 Share Posted July 9, 2018 Hi, how can I access the CKE background elemet via JS? I need to add / remove css classes to change the bg-color. Any hints are greatly appreciated. Link to comment Share on other sites More sharing options...
louisstephens Posted July 9, 2018 Share Posted July 9, 2018 I havent tested this, but I did find this: https://stackoverflow.com/questions/14039638/apply-background-color-in-ckeditor-textarea 1 Link to comment Share on other sites More sharing options...
horst Posted July 9, 2018 Author Share Posted July 9, 2018 Many thanks. I have tried a lot from SO links in the last past 2 hours. But all of them result in 'undefined' objects. In pW PageEditor, the CKE textarea is within an iframe, maybe that is the reason? Link to comment Share on other sites More sharing options...
horst Posted July 9, 2018 Author Share Posted July 9, 2018 (edited) Ah, this seems to be better place to look: https://docs.ckeditor.com/ckeditor4/latest/api/CKEDITOR_dom_document.html#method-getBody EDIT: No, it only gets the dom elements from the edit page what is the parent page of the page in cke iframe. ? Edited July 9, 2018 by horst Link to comment Share on other sites More sharing options...
horst Posted July 10, 2018 Author Share Posted July 10, 2018 Ok, the culprit was that CKE needs some time on startup to dynamically create the iframes. Therefore all those tries running on document load failed. As a workaround I use setTimeout() with a delay of 1000 ms to start finding the iframes. Will look into CKE API, if there is something that can be queried that indicates ready loaded CKE and use this instead of my workaround. But for today I'm finished with work. ? 3 Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now