Allow script tags in content item

Posted by Community Admin on 04-Aug-2018 21:17

Allow script tags in content item

All Replies

Posted by Community Admin on 29-Jun-2011 00:00

Is there a way to configure the content item to allow <script> tags?  Right now, they're being stripped.

Posted by Community Admin on 30-Jun-2011 00:00

Hi Suzanne,

Implementing scripts in the Html field is disabled by default. Today we use a variety of Content Filters which you can see here:

demos.telerik.com/.../defaultcs.aspx

As you can see, in your case you will have to disable is the RemoveScripts filter. 

First you will have to map your editor template ( you need to map a custom template over default one ) in Sitefinity and then specify which Content Filters should be enabled. Create your editor template and register it in Sitefinity by going to Settings > Advanced > Controls > ViewMap > Telerik.Sitefinity.Modules.GenericContent.Web.UI.ContentBlockDesigner. In LayoutTemplatePath field enter the path to your template( ~/Templates/Editor.ascx ).

Please refer to this forum thread where my colleague Boyan gave some more information about the way you can achieve that ( in addition to this answer here ).

You can paste the following code between <div>, </div> tags of your editor .ascx file:

<sf:HtmlField
       ID="htmlEditor"
       runat="server"
       Width="99%"
       Height="370px"
       EditorContentFilters="DefaultScripts"<%--replace with needed filters--%> 
       EditorStripFormattingOptions="MSWord,Css,Font,Span,ConvertWordLists" 
       DisplayMode="Write" 
       FixCursorIssue="True">  
   </sf:HtmlField>

Replace DefaultScripts with the names of those filters you want to include in your project.

Also if you want to have flawless working code use Script Widgets ( Java Script ) instead of Content Block for your scripts.

Kind regards,
Victor Velev
the Telerik team
Do you want to have your say in the Sitefinity development roadmap? Do you want to know when a feature you requested is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items

This thread is closed