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?
modifying the contents of the FCKeditor editor
Moderator: General Moderators
- RobertGonzalez
- Site Administrator
- Posts: 14293
- Joined: Tue Sep 09, 2003 6:04 pm
- Location: Fremont, CA, USA
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
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
Real programmers don't comment their code. If it was hard to write, it should be hard to understand.
-
godforhire
- Forum Newbie
- Posts: 1
- Joined: Mon Jul 24, 2006 8:49 am
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:
(To use with IE, I believe you have to change 'contentDocument' to 'contentWindow'.)
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);
}-
nickvd
- DevNet Resident
- Posts: 1027
- Joined: Thu Mar 10, 2005 5:27 pm
- Location: Southern Ontario
- Contact:
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:
as to the OP's question, prior to loading the editor it's easy, after it's loaded, I'm not too sure...
Code: Select all
oEditor = FCKeditorAPI.GetInstance('theEditor') ;
var fileContents = oEditor.GetXHTML();