Andrew Davey Andrew Davey - 18 days ago 10
Javascript Question

Add class or ID to FCKeditor's editable iframe body

I'm using FCKeditor to edit the contents of a div. This content div has an ID set so my CSS can target the p, li, img, etc tags contained. I want the FCKeditor's contents to look the same as my div's contents. I have @import'd my stylesheet in the fck_editorarea.css, but of course the FCKeditor body does not have the ID set, so the styles are not applied.

I have been trying to write a plugin for FCK to set the ID of the body tag in the inner iframe but can't get it working. Can anyone suggest a solution or better approach?

Answer

There is no need for a plugin. Find these lines in FCKedotor's confing file, fckconfig,js

// This will be applied to the body element of the editor
FCKConfig.BodyId = '' ;
FCKConfig.BodyClass = '' ;

and change empty body id to whatever you need.