TinyMCE - Insert HTML Code
Thursday, 3. May 2007, 16:31:34
By default, TinyMCE only allows specific tags in it’s editor content body. These are known as valid tags. Even so, you can tell it to allow additional tags which you’ll specify in the TinyMCE initialization function.
Usually, you will initialize TinyMCE using something like this :
<script type="text/javascript">
<!–
tinyMCE.init({
theme : "advanced",
mode : "exact",
elements : "editorContent",
width : "565",
height : "200"
});
–>
</script>
…then you’ll need to add a new line, just below the “height” parameter. Something like this :
extended_valid_elements : "input[name|size|type|value|onclick]",
The line of code shown above, will allow you to insert the <INPUT> element with 5 different attributes : “name”, “size”, “type”, “value”, “onclick”. Please note that you can add more attributes as well. Just seperate each attribute as shown above. Not only that, but you can add more elements as well. Something like this :
extended_valid_elements : "input[name|size|type|value|onclick],iframe[height|width|src]",
And that’s it! This will allow you to insert your needed HTML elements into TinyMCE editor without it being stripped automatically.
You’ll end up with your init(); function looking something like this :
<script type="text/javascript">
<!–
tinyMCE.init({
theme : "advanced",
mode : "exact",
elements : "editorContent",
width : "565",
height : "200",
extended_valid_elements : "input[name|value|size|class|onclick|type],iframe[name|src|framespacing|border|frameborder|scrolling|title|height|width]"
});
–>
</script>















