I create the editor using PHP, but I would like to be able to set the content client side, ie someone clicks a link and that sets the content of the editor to something. Any suggestions on how to do this?
Sat, 12/11/2004 - 17:31
#1
RE: Setting the content of the editor, client
use the setContent function pass it the instanceName for the editor and the content you want to put in the editor. Just for good measure the function returns what was in the editor before the content was changed.
If the function fails it will return false.
Simple example using a textarea and button below the JS code.
<script type="text/javascript">
<!--
function setContent(instanceName,content) {
editor_frame = document.getElementById(instanceName+'___Frame');
if (editor_frame!=null) {
editor_source = editor_frame.contentWindow.document.getElementById('eEditorArea');
if (editor_source!=null) {
oldcontent=editor_source.contentWindow.document.body.innerHTML; editor_source.contentWindow.document.body.innerHTML=content;
return oldcontent;
} else { return false; }
} else { return false; }
}
//-->
</script>
<textarea id="newcode"></textarea>
<input type="button" onclick="setContent('FCKeditor1',document.getElementById('newcode').value);" value="Update Content" />
Good luck...
RE: Setting the content of the editor, client sid
Out of interest, do you happen to have a js wrapper that goes along with this that converts standard text and changes the whitespace any any other obvious bits to HTML ready for going into the editor?