Wysiwyg / TinyMCE stripping Javascript code
6 posts by 3 authors in: Forums > CMS Builder
Last Post: January 15, 2010 (RSS)
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: [garyhoffmann] Wysiwyg / TinyMCE stripping Javascript code
By Dave - January 15, 2010
It's better not to do it that way. What pages do you need it on? Is it possible to put it in the viewer file?
Or create a checkbox called show-topbiz and then have this in the viewer:
<?php if ($record['show-topbiz']): ?>
<SCRIPT LANGUAGE="JavaScript" src="http://code.javahd.com/js/topbiz.js" type="text/JavaScript"></SCRIPT>
<?php endif ?>
Would that work for you?
interactivetools.com
Re: [Dave] Wysiwyg / TinyMCE stripping Javascript code
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
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.
Chris
Re: [chris] Wysiwyg / TinyMCE stripping Javascript code
Gary.
Re: [garyhoffmann] Wysiwyg / TinyMCE stripping Javascript code
Gary.