+1-888-365-2779
Try Now
More in this section

Forums / General Discussions / Adding script tag in generic content

Adding script tag in generic content

4 posts, 0 answered
  1. Jae Hong
    Jae Hong avatar
    29 posts
    Registered:
    07 May 2012
    22 Dec 2012
    Link to this post
    Could anyone help me how to add javascript tag in generic content? When I switch it to view mode it is disappeared. I searched forum, but all answer are old. Is it possible to configure generic content in backend? I would like to add script tag in a news item content.
  2. Jae Hong
    Jae Hong avatar
    29 posts
    Registered:
    07 May 2012
    24 Dec 2012 in reply to Jae Hong
    Link to this post

    I figured out by myself (I'm using sitefinity 5.3). If anyone looking for adding javascript in RadEditer such as content block, news Item, etc... follow steps below:

    [Add javascript in news (insert and edit mode)]

    1. Settings - Advanced - News - Controls - NewsBackend - Views - NewsBackendInsert(NewsBackendEdit) - Sections - MainSection - Fields - Content

    2. Add 'EncodeScripts' (built-in content filters) in "Rad Editor's content filters" field and save it. Now, you can add javascript in news item content (you can add this value in other places such as Content

    Here are list of RadEditor built-in content filters:

    RemoveScripts: this filter removes script tags from the editor content. Disable the filter if you want to insert script tags in the content.

    EncodeScripts: this filter encodes all script tags from the content.

    MakeUrlsAbsolute: this filter makes all URLs in the editor content absolute (e.g. "http://server/page.html" instead of "page.html"). This filter is DISABLED by default.

    FixUlBoldItalic: this filter changes the deprecated u tag to a span with CSS style.

    IECleanAnchors: Internet Explorer only - this filter removes the current page url from all anchor(#) links to the same page.

    FixEnclosingP: this filter removes a parent paragraph tag if the whole content is inside it.

    MozEmStrong: this filter changes b to strong and i to em in Mozilla browsers.

    ConvertFontToSpan: this filter changes deprecated font tags to compliant span tags.

    OptimizeSpans: this filter changes removes unneeded span elements.

    ConvertToXhtml: this filter converts the HTML from the editor content area to XHTML.

    IndentHTMLContent: this filter indents the HTML content so it is more readable when you view the code.

    ConvertCharactersToEntities: this filter converts reserved characters to their html entity names.

    PdfExportFilter: this filter fixes some pdf export issues.

    ConvertInlineStylesToAttributes: this filter converts XHTML compliant inline style attributes to Email compliant element attributes.

    DefaultFilters: the default editor behavior. All content filters except MakeUrlsAbsolute are activated.

  3. Basem
    Basem avatar
    131 posts
    Registered:
    22 Dec 2010
    27 Dec 2012 in reply to Jae Hong
    Link to this post

    Thanks for this, but this erases the DefaultFilters and only adds EncodeScripts back. This will have a bad effect if not intended because there are many filters activated by default (<u>test</u> will not be auto-replaced with <span style="text-decoration: underline;">test</span> for example).

    Instead you will have to add all the default filters back and leave out the "RemoveScripts" like this:
    EncodeScripts,FixUlBoldItalic,FixEnclosingP,IECleanAnchors,MozEmStrong,ConvertFontToSpan,ConvertToXhtml,IndentHTMLContent,ConvertCharactersToEntities,ConvertInlineStylesToAttributes,PdfExportFilter 

  4. Jae Hong
    Jae Hong avatar
    29 posts
    Registered:
    07 May 2012
    28 Dec 2012 in reply to Basem
    Link to this post

    Yes, I know as you mentioned. There are only two ways to set built-in filters either default or manually add filters. In my case, I need to add script in the news item content so I just added filters that I need in NewsItem - NewsBackend - Content control. If there is no javascript to be added in the content, then leave it as default would be best. depends on developer's flavor.

    I don't think "IndentHTMLContent" is added in default filter setting. I added this filter manually; however, it automatically indent html tags, but it also hides double quotes except style. (i.e. id="..." or class="..." will be shown as id=... and class=... I guess it's little bug.)

4 posts, 0 answered