Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

Archive /

Our old forums are still available as a read-only archive.

Moderators: martimiz, Sean, biapar, Willr, Ingo, simon_w

TinyMCE Eating onclick


Reply


3 Posts   3025 Views

Avatar
JGC

Community Member, 25 Posts

26 November 2008 at 2:21am

Edited: 26/11/2008 3:09am

Hi, I'm trying to get TinyMCE to let the user enter onclick properties through the CMS, for forms. I've had to add the form to the allowed elements in "cms/javascript/tinymce.template.js" and my line 43/44 reads:

      valid_elements : "+a[id|rel|rev|dir|tabindex|accesskey|type|name|href|target|title|class],-strong/-b[class],-em/-i[class],-strike[class],-u[class],#p[id|dir|class|align],-ol[class],-ul[class],-li[class],br,img[id|dir|longdesc|usemap|class|src|border|alt=|title|width|height|align],-sub[class],-sup[class],-blockquote[dir|class],-table[border=0|cellspacing|cellpadding|width|height|class|align|summary|dir|id|style],-tr[id|dir|class|rowspan|width|height|align|valign|bgcolor|background|bordercolor|style],tbody[id|class|style],thead[id|class|style],tfoot[id|class|style],-td[id|dir|class|colspan|rowspan|width|height|align|valign|scope|style],-th[id|dir|class|colspan|rowspan|width|height|align|valign|scope|style],caption[id|dir|class],-div[id|dir|class|align],-span[class|align],-pre[class|align],address[class|align],-h1[id|dir|class|align],-h2[id|dir|class|align],-h3[id|dir|class|align],-h4[id|dir|class|align],-h5[id|dir|class|align],-h6[id|dir|class|align],hr[class],dd[id|class|title|dir],dl[id|class|title|dir],dt[id|class|title|dir],iframe[src|height|width|frameborder],form[id],input[type|id|onclick|value]",
      extended_valid_elements : "img[class|src|alt|title|hspace|vspace|width|height|align|onmouseover|onmouseout|name],input[type|id|onclick|value]"

I can tell it to allow *{*} but that still doesn't stop it eating the onclick :/ (NOTE: Used {} for here as the forum doesn't escape square brackets properly)

Even with the "form[id],input[type|id|onclick|value]" at the end, it's not letting me put onclick events on to the input elements:

<p><input type="button" value="Calculate" onclick="getBuyToLet();" /></p>


becomes

<p><input type="button" value="Calculate" /></p>

Does anyone have any ideas why? This is fairly urgent.

Thanks.

Avatar
Willr

Forum Moderator, 5513 Posts

26 November 2008 at 7:05pm

If tinymce is configured to except onclick values then you probably need to look into the HTMLText fieldtype - this might be stripping JS aswell.

Avatar
JGC

Community Member, 25 Posts

26 November 2008 at 10:39pm

Can't find anything in there, but I was able to sort it by

1) Applying an ID instead of an onclick
2) Putting this in the meta data for the page (Content/Second sub tab/Advanced)

window.onload = function () { document.getElementById('myID').onclick = function () { doSomething(); }}


3) Editing Page.ss to include $MetaTags in the head.

Thanks for the ideas though :)