Thursday, 3. May 2007, 16:31:34
So, you might be reading this because you are having trouble inserting HTML code into your TinyMCE WYSIWYG editor. Off course you can add the HTML, but it automatically gets stripped by the editor and just disappears.
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>