Page 1 of 1
modifying the contents of the FCKeditor editor
Posted: Thu Jul 13, 2006 6:15 pm
by Burrito
I could dig through this code to figure it out, but I thought I'd just ask first.
does anyone know a quick and easy way to modify the contents of the editor frame for FCKeditor using JS.
example:
I have an instance of FCKeditor loaded on my page, and I want to change the contents of the iframe using a select box or somethign similar.
I can't simply change the src element because that just changes the page source and removes the editing capabilites.
anyone done this?
Posted: Fri Jul 14, 2006 1:35 am
by RobertGonzalez
Are you asking how you change the text that is in the FCKEditor box itself? I am a little unclear on the question. Also, does it have to be an iFrame, or can you resort to a textarea?
Posted: Fri Jul 14, 2006 9:30 am
by Burrito
Everah wrote:Are you asking how you change the text that is in the FCKEditor box itself?
yes
Everah wrote:Also, does it have to be an iFrame, or can you resort to a textarea?
must be iframe.
I'm using the php version (to build the editor).
Posted: Fri Jul 14, 2006 9:56 am
by pickle
The id of the iframe is 'editor___Frame'. Inside that, I believe the code is displayed in a table cell with id 'xEditingArea'.
Failing finding a way to get that to work, you could try the poorly commented, but likely well built API:
http://wiki.fckeditor.net/Developer%27s ... script_API
Posted: Fri Jul 14, 2006 10:50 am
by Burrito
excellent...I'll give that a try.
thx pickle.
Posted: Mon Jul 24, 2006 9:04 am
by godforhire
I had a similar problem and couldn't find any info on it. However, after some trial and error, I've managed to retrieve the contents of the text inside the xEditingArea. Below is the code (test on Firefox only), hope it's of some use:
Code: Select all
function showFC() {
var contents;
ifrRef =document.getElementById('editor___Frame');
var hCode = ifrRef.contentDocument.getElementById("xEditingArea");
var iFCode = hCode.getElementsByTagName("IFRAME")[0];
contents = iFCode.contentDocument.getElementsByTagName("BODY")[0].innerHTML
alert(content);
}
(To use with IE, I believe you have to change 'contentDocument' to 'contentWindow'.)
Posted: Mon Jul 24, 2006 9:44 pm
by nickvd
if you just want to retrieve the page that's in the editor, all you need to do is use the API object that is provided:
Code: Select all
oEditor = FCKeditorAPI.GetInstance('theEditor') ;
var fileContents = oEditor.GetXHTML();
as to the OP's question, prior to loading the editor it's easy, after it's loaded, I'm not too sure...