Call this function like "setEditorCss('color: #322805; background-color: #F7C928;')"
(Note that the cssText property used in this function has no public standard applied to it. And that you have to fill in the instanceName of your FCKeditor in the 'GetInstance' method)
function setEditorCSS(editorCSS)
{
if (!window.FCKeditorAPI)
{
alert("FCKeditor not loaded yet");
return false;
}
if (!window.FCKEditor)
{
// get the main FCKeditor object
var FCKEditor = FCKeditorAPI.GetInstance('FCKeditor') ;
}
if (!window.FCKEditorDOM)
{
// Get the Editor Area DOM (Document object).
var FCKEditorDOM = FCKEditor.EditorDocument ;
}
FCKEditorDOM.body.style.cssText += editorCSS;
}
(Note that the cssText property used in this function has no public standard applied to it. And that you have to fill in the instanceName of your FCKeditor in the 'GetInstance' method)
function setEditorCSS(editorCSS)
{
if (!window.FCKeditorAPI)
{
alert("FCKeditor not loaded yet");
return false;
}
if (!window.FCKEditor)
{
// get the main FCKeditor object
var FCKEditor = FCKeditorAPI.GetInstance('FCKeditor') ;
}
if (!window.FCKEditorDOM)
{
// Get the Editor Area DOM (Document object).
var FCKEditorDOM = FCKEditor.EditorDocument ;
}
FCKEditorDOM.body.style.cssText += editorCSS;
}
RE: Change editor document style at runtime
Wonderful, but it always tells me FCKEditor is not loaded yet".
Maybe because I call this function in the ASP function that create a new instance. I call it two times and it colors only one of the two textareas, while the second isn't loaded yet and it tells me that Error.
Any suggestion?
Thanks
RE: Change editor document style at runtime
RE: Change editor document style at runtime
FCKeditorAPI.GetInstance('FCKeditor1').EditorDocument.body.style.cssText += 'color: #322805; background-color: #F7C928;';
Is there a way to make FCKeditor use a specific stylesheet on startup (a stylesheet that is usable in pages)?
I also want to be able to switch the stylesheet above whenever I want to, after the editor has been loaded.
That would be cool.
I do not want to switch the css on a one by one attribute way.
I want to switch stylesheets......
Is this future music for FCKeditor?
RE: Change editor document style at runtime
> Is there a way to make FCKeditor use a specific stylesheet on startup (a stylesheet that is usable in pages)?
Just read the documentation:
http://wiki.fckeditor.net/Developer%27s ... torAreaCSS
> I also want to be able to switch the stylesheet above whenever I want to, after the editor has been loaded.
you'll need to write some javascript to do that. Not hard to do (maybe just doing a getxhtml, change stylesheet and setxhtml might work, if not just DOM manipulation)
RE: Change editor document style at runtime
Actually this can be done much easier through the API's event functionality :
<script type="text/javascript">
function FCKeditor_OnComplete( editorInstance )
{
FCKeditorAPI.GetInstance('FCKeditor1').EditorDocument.body.style.cssText += 'color: #322805; background-color: #F7C928;';
}
</script>
RE: Change editor document style at runtime
Don't do FCKeditorAPI.GetInstance('FCKeditor1').EditorDocument...
but do editorInstance.EditorDocument...