TinyMCE - Insert HTML Code
Thursday, May 3, 2007 4:31:34 PM
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>















mank1 # Saturday, May 12, 2007 12:41:22 PM
Thanks for posting this.
Antonie PotgieterContrid # Saturday, May 12, 2007 12:51:44 PM
See...they actually block most elements due to security reasons.
You need to enable the ones you want to allow.
Sergio_dsc # Thursday, July 5, 2007 6:33:50 AM
This post is just i was searching but... I've added the extended_valid_elements and when I try to write manually a link, it shows like this:
<a href="http://www.uuuuuuuu.com">www.uuuuuuu.com</a>
What might I edit to solve the problem?
Thanks a lot!!!
Sergio_dsc # Thursday, July 5, 2007 6:34:51 AM
(without strips)
"<a href="http://www.newmusicalpress.com">Nuevaprensamusical</a>"
Antonie PotgieterContrid # Thursday, July 5, 2007 6:59:34 AM
Sergio_dsc # Thursday, July 5, 2007 8:06:35 AM
(thanks)
Antonie PotgieterContrid # Thursday, July 5, 2007 8:33:50 AM
Antonie PotgieterContrid # Thursday, July 5, 2007 8:38:16 AM
tinyMCE.init({ entity_encoding:"raw" });...that will allow all html characters to stay intact. Have you tried this? If not, please try it, since it will most probably solve your problem.
Put that line below you current, comma-seperated list of options.
deoriginalclaritydigital # Thursday, November 22, 2007 8:58:48 AM
I just wanted to add also that this:
tinyMCE.init({
entity_encoding:"raw"
});
strips tinyMCE completely from the textarea, and as it suggests, you end up with raw html...jus the way anyone would love it....
Thanks again...youre a champ!
Lea
bgibson # Saturday, August 2, 2008 3:27:34 AM
webmastertj # Friday, February 6, 2009 4:03:12 PM
sorry guys .. but i'm completely a beginner, can anybody tell me in which file to add these lines of code. because i'm using joomla 1.5, whenever i put the <form></form> tag it disappears.
regards
tj