Script tags in TinyMCE fields are not saving correctly

血红的双手。 提交于 2020-01-02 03:25:09

问题


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


回答1:


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.




回答2:


There seems to be a bug where if a script tag is wrapped in a div TinyMce dumps the script. (even if you have extended_valid_elements correctly) TinyMCE can be very annoying to use




回答3:


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

<code>
     <script>alert("abc");</script>
</code>


来源:https://stackoverflow.com/questions/24614301/script-tags-in-tinymce-fields-are-not-saving-correctly

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!