Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Script tags in TinyMCE fields are not saving correctly

I am running tinyMCE on my site and I'm trying to insert script tags. I am trying to insert my script tags into the body of the source of the tinyMCE instance.

However, when I do I get problems. When I submit the form including the tinyMCE element It strips the tags.

I have tried the following lines below with still no success.

  • allow_script_urls: true
  • valid_elements : '*[*]'
  • extended_valid_elements: 'script[language|type]'

One thing I have noticed though that if I have to post the script code to the section of the source code of the tinymce instance and it works. However, I need to be able to add it to the <body> of the tinymce instance so I can see previews etc of it.

Below is the script tag I'm trying to upload.

<script type="text/javascript" src="http://resources.32red.com/ad.aspx?pid=237638&bid=3344"></script>

Can anyone shed any light on this?

Thanks

like image 777
WayneP Avatar asked Jul 07 '14 15:07

WayneP


2 Answers

Try the following:

extended_valid_elements: 'script[language|type|src]'

I see that you've already tried updating the extended_valid_elements property using

'script[language|type]' but you forgot to allow the src attribute for the script tags

so right now the src attribute is being stripped out.

like image 89
dmullings Avatar answered Oct 16 '22 08:10

dmullings


What I did to solve the problem was putting the script block inside a tag <code> tag.

<code>
     <script>alert("abc");</script>
</code>
like image 27
Alex Celmer Avatar answered Oct 16 '22 08:10

Alex Celmer