More in this section

Forums / Bugs & Issues / Allow script tags in content item

Allow script tags in content item

2 posts, 0 answered
  1. Suzanne
    Suzanne avatar
    43 posts
    Registered:
    12 Jul 2012
    29 Jun 2011
    Link to this post
    Is there a way to configure the content item to allow <script> tags?  Right now, they're being stripped.
  2. Victor Velev
    Victor Velev avatar
    1345 posts
    Registered:
    06 Jul 2015
    30 Jun 2011
    Link to this post
    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:

    http://demos.telerik.com/aspnet-ajax/editor/examples/builtincontentfilters/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
2 posts, 0 answered