I want to be able to access the value/content in the editing area via JavaScript. I cannot seem to identify the proper object path to access this.
Here is some sample code:
<form name="editor">
<div>
<input type="hidden" id="FCKeditor1" name="FCKeditor1" value="" style="display:none" />
<input type="hidden" id="FCKeditor1___Config" value="SkinPath=/fckeditor/skins/office2007/" style="display:none" />
<iframe id="FCKeditor1___Frame" src="/fckeditor/editor/fckeditor.html?InstanceName=FCKeditor1&Toolbar=Default" width="685" height="500" frameborder="0" scrolling="no"></iframe>
</div>
</form>
Since the form posts the editing area text as the field FCKeditor1, I figured I could access the value via JavaScript using "document.editor.FCKeditor1.value", but that does not work since the editing area is not part of a form and is in the iframe. I tried accessing document.getElementById('FCKeditor1___Frame').document, but that comes up undefined.
Does anyone know the object path to access this? Is there a built-in method to get this value I am missing?
Thanks
Here is some sample code:
<form name="editor">
<div>
<input type="hidden" id="FCKeditor1" name="FCKeditor1" value="" style="display:none" />
<input type="hidden" id="FCKeditor1___Config" value="SkinPath=/fckeditor/skins/office2007/" style="display:none" />
<iframe id="FCKeditor1___Frame" src="/fckeditor/editor/fckeditor.html?InstanceName=FCKeditor1&Toolbar=Default" width="685" height="500" frameborder="0" scrolling="no"></iframe>
</div>
</form>
Since the form posts the editing area text as the field FCKeditor1, I figured I could access the value via JavaScript using "document.editor.FCKeditor1.value", but that does not work since the editing area is not part of a form and is in the iframe. I tried accessing document.getElementById('FCKeditor1___Frame').document, but that comes up undefined.
Does anyone know the object path to access this? Is there a built-in method to get this value I am missing?
Thanks
Re: How do you access the editing area content from JavaScript
Has anyone figured out a way to get the current value of the editor from Javascript?
If I create the editor and pass it an ID like "test123", and then call CreateHtml(), it creates a hidden INPUT field with that ID, but the ID doesn't get an updated value as I type. So I'm confused about how one is supposed to go about getting the value.
- Jim
Re: How do you access the editing area content from JavaScript
First off, the value is not automatically stuffed into an INPUT field like I'd expected. Secondly, there is an editor instance which has a GetHTML method but that instance is NOT the same as the object you create with "new FCKeditor()". They are entirely different.
Now the solution.
- Jim
Re: How do you access the editing area content from JavaScript
Re: How do you access the editing area content from JavaScript
thanks
Re: How do you access the editing area content from JavaScript
i'm not sure how correct this is..but as my function was picking up the correct textarea (but not its contents) and storing its name in a var, i have just used this var like so
Re: How do you access the editing area content from JavaScript
var editor = new FCKeditor(eleFckComment);
var inst = FCKeditorAPI.GetInstance(eleFckComment);
alert(inst.GetHTML());
where eleFckComment is the name of my element on the page (i.e. fckComment) and it gives me a error on FCKeditor being not defined. Any ideas on what I am doing wrong here?