Wysiwyg / TinyMCE stripping Javascript code

6 posts by 3 authors in: Forums > CMS Builder
Last Post: January 15, 2010   (RSS)

Hi,

I'm using the HTML button from within TinyMCE and trying to insert the following:

<SCRIPT LANGUAGE="JavaScript" src="http://code.javahd.com/js/topbiz.js" type="text/JavaScript"></SCRIPT>

It's stripping out the "src=..." parameter.

I also tried to insert this:

<script language="JavaScript" type="text/javascript">
v_theflv='topbiz.flv';
v_flvbase='hosted';
v_alignvideo='bottomleft';
</SCRIPT>

ended up getting this:

<script language="JavaScript" type="text/javascript">// <![CDATA[
v_theflv='topbiz.flv';
v_flvbase='hosted';
v_alignvideo='bottomleft';
// ]]></script>

Any ideas what I can do to insert javascript into a page's content section?

Thanks in advance,
Gary

Re: [Dave] Wysiwyg / TinyMCE stripping Javascript code

This is just one example - I may need to have embedded javascript on many pages, different on each page, so having it in the viewer would not work.

Do you know what's causing tinymce to change the javascript? There must be a setting somewhere within it causing it.

Otherwise I'll have to come up with some other "trick" to get around it. I would just rather not have to play all these coding tricks.

Re: [garyhoffmann] Wysiwyg / TinyMCE stripping Javascript code

By Chris - January 15, 2010

Hi Gary,

It looks like the wysiwyg editor (tinyMCE) strips out <SCRIPT SRC> attributes by default. If you're comfortable editing the PHP you can turn that feature off. Here's how:

- Open cmsAdmin/lib/wysiwyg.php
- Make a backup copy of that file
- Search for 'entity_encoding'
- After that line, add this line (in red):

entity_encoding : "raw", // ...
extended_valid_elements : "script[src|type|language]",


Then save that file and reload your editor and you should be able to enter your script tags in the HTML.

Regarding the <![CDATA[...]]> wrapper, does that prevent your JavaScript code from running? I think that's simply done to make your code XHTML-compliant.

Hope that helps, let me know if you have any further problems with that or need more assistance.
All the best,
Chris

Re: [chris] Wysiwyg / TinyMCE stripping Javascript code

Awesome - I will give that a shot and see what happens - THANK YOU.

Gary.

Re: [garyhoffmann] Wysiwyg / TinyMCE stripping Javascript code

That did the trick! Thanks tons.
Gary.