Contridentuallity

Not a fact, a theory!?

TinyMCE - Insert HTML Code

, , , ,

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>

Biltong & DVDsWordpress Mailing List v1.2.3

Comments

mank1 Saturday, May 12, 2007 12:41:22 PM

Excellent. I was wondering how to accomplish this, but I couldn't find a straight answer.

Thanks for posting this.

Antonie PotgieterContrid Saturday, May 12, 2007 12:51:44 PM

It's a pleasure. I'm glad that you found it useful.
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

Hi!

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&quot;&gt;www.uuuuuuu.com&lt;/a&gt;

What might I edit to solve the problem?

Thanks a lot!!!

Sergio_dsc Thursday, July 5, 2007 6:34:51 AM

Ups... it shows this...
(without strips)
"<a href="http://www.newmusicalpress.com&quot;&gt;Nuevaprensamusical&lt;/a&gt;"

Antonie PotgieterContrid Thursday, July 5, 2007 6:59:34 AM

What exactly seems to be the problem? Doesn't it output the link, but rather the html entities in the wysiwyg mode?

Sergio_dsc Thursday, July 5, 2007 8:06:35 AM

Yes! I've been trying adding a line in config about entities, but it doesn't work sad

(thanks)

Antonie PotgieterContrid Thursday, July 5, 2007 8:33:50 AM

Please elaborate on what code you inserted. Use the code tags in here and show me what you have. I might be able to help you.

Antonie PotgieterContrid Thursday, July 5, 2007 8:38:16 AM

The only thing I can think of right now is the entity_encoding option.

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

You are a bloody legend....I couldn't even find this info stickied in the tinyMCE support forum (how lame)... Infact, I joined this site just to say thanks.... I had been working on getting that done for a while.

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

I am trying to add a paypal pay now button to my web page using Site Builder with Tiny MCE. When I create the butto on paypal and copy the html code this is what it looks like and it works perfect from the desktop. Example of copied HTML Code: <form action="https://www.paypal.com/cgi-bin/webscr" method="post"> <input type="hidden" name="cmd" value="_xclick"> <input type="hidden" name="business" value="bgibson@ptwinsock.com"> <input type="hidden" name="undefined_quantity" value="1"> <input type="hidden" name="item_name" value="ProTrainer WinSock"> <input type="hidden" name="amount" value="35.00"> <input type="hidden" name="shipping" value="0.00"> <input type="hidden" name="no_shipping" value="2"> <input type="hidden" name="return" value="http://www.ptwinsock.com"> <input type="hidden" name="currency_code" value="USD"> <input type="hidden" name="tax" value="0.00"> <input type="hidden" name="lc" value="US"> <input type="hidden" name="bn" value="PP-BuyNowBF">
<input type="hidden" name="on0" value="Color">Color <select name="os0">
<input type="image" src="https://www.paypal.com/en_US/i/btn/btn_buynowCC_LG.gif" border="0" name="submit" alt="PayPal - The safer, easier way to pay online!"> </form> When I paste this into Site Builders HTML Source Editor for the page, this is what it does to it. Example of pasted HTML Code after updating: <form method="post" action="https://www.paypal.com/cgi-bin/webscr"></form><input name="cmd" type="hidden" /> <input name="business" type="hidden" /> <input name="undefined_quantity" type="hidden" /> <input name="item_name" type="hidden" /> <input name="amount" type="hidden" /> <input name="shipping" type="hidden" /> <input name="no_shipping" type="hidden" /> <input name="return" type="hidden" /> <input name="currency_code" type="hidden" /> <input name="tax" type="hidden" /> <input name="lc" type="hidden" /> <input name="bn" type="hidden" />
<input name="on0" type="hidden" />Color <select name="os0"> </select>
<input name="submit" border="0" src="https://www.paypal.com/en_US/i/btn/btn_buynowCC_LG.gif" alt="PayPal - The safer, easier way to pay online!" type="image" />   <form method="post" action="https://www.paypal.com/cgi-bin/webscr"></form></form>

webmastertj Friday, February 6, 2009 4:03:12 PM

Hi !

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

Write a comment

New comments have been disabled for this post.

May 2012
S M T W T F S
April 2012June 2012
1 2 3 4 5
6 7 8 9 10 11 12
13 14 15 16 17 18 19
20 21 22 23 24 25 26
27 28 29 30 31