If you want to assign value to iframe innerHTML its just easy. All you have to do is just assign the value of the textarea to the iframes innerHTML property. If the value is html source, the iframe will give a rich text look. There may a situation as well if you want to pull mysql html data and format it inside a html editor.
lets say you have a textarea where you have a html code and want to be inserted to iframe to edit inside the rich text editor.
myeditor = document.getElementById('rte').contentWindow.document;
function LoadData(obj)
{
alert(document.getElementById(obj).value);
myeditor.body.innerHTML= document.getElementById(obj).value;
}
The html code of the page with the form elements.
<form action="" method="post" onSubmit="doCheck('mybox');">
<textarea name="textareabox" id="mybox">This is a <b>bold</b> sample textarea</textarea>
<input type="button" id="btnLoad" onsubmit="LoadData('textareabox')">
</form>
and
- VERY IMPORTANTLY
If you try to set the value of innerHTML of iframe dynamically while still iframe loads, the assigning the value wont work. The above should work because it is called from click button after the iframe has completely loaded.
Similar Posts:
- iFrame in javascript wont work in Firefox [solved]
- A Simple WYSIWYG Editor in Javascript
- how to get selected textarea value using javascript
- how to change div content in javascript?
- Lightweight PHP WYSIWYG HTML Editor
- how to hide textarea?
- iframe value to textbox in javascript
- Free Markup TextArea HTML Editor in Javascript
- Free BBCode/HTML Markup Editors!
- Best Free Web based WYSIWYG html editors


February 18, 2010
Interesting Idea!
Thanks you very much admin..