Javascript within RadEditor is stripped

6 posts, 0 answers
  1. J
    J avatar
    3 posts
    Member since:
    Jul 2007

    Posted 31 Jul 2007 Link to this post

    I'm using RadEditor on a MOSS page with the following code:
    <radE:RadHtmlField ID="PageContent" FieldName="PublishingPageContent" runat="server"/>
    The control is used for the main content of a page, i.e. is not being used within a list.

    When I enter javascript into the body of the editor, for example <a href="#" onclick="alert('hello');">hello</a>, the javascript code is stripped out.

    I have seen recommendations to enable various properties within the config file, but it's not clear how to specify a config file when the RadHtmlField method is used.

    Can you explain how to keep javascript from being removed?
  2. Georgi Tunev
    Admin
    Georgi Tunev avatar
    7207 posts

    Posted 01 Aug 2007 Link to this post

    Hello J,

    In the new version of RadEditor for MOSS standard edition which will appear in a couple of days, it will be possible to insert Javascripts in certain scenarios, however some additional properties must be set :

    RadEditor in WebPart:
    Set (add if not present) the AllowScripts property to true in ConfigFile.xml

    RadEditor in WCM:
    Set (add if not present) the AllowScripts and AllowSpecialTags properties to true in ConfigFile.xml

    SharePoint forms scenario (Lists, Wikis, Blogs, etc.)
    You cannot use Javascript in RadEditor in such scenario. There RadEditor does not have control over the presentation view which means that we cannot control the output when it is not in edit mode.



    The configuration file for RadEditor differs depending on which editor you want to setup.

    Web Part and WCM scenario
    You need to modify the ConfigFile.xml which is located in the following folder:
    /Program Files/Common Files/Microsoft Shared/web server extensions/wpresources/RadEditorSharePoint/4.3.0.0__1f131a624888eeed/RadControls/Editor/

    SharePoint forms scenario (Lists, Wikis, Blogs, etc.)
    You need to modify the ListConfigFile.xml located in the same folder

    As for your second question, you can set the ConfigFile and ToolsFile properties of the RadEditor for MOSS in the WCM field by using the SharePoint Designer. To do so:

    1. Open SharePoint Designer and navigate to the desired page
    2. Open the page and choose Edit Page Layout
    3. Click in the radE:RadHtmlField control so the TagProperties pane is updated with the control
    4. Set the desired properties



    All the best,
    Georgi Tunev
    the Telerik team

    Instantly find answers to your questions at the new Telerik Support Center

  3. J
    J avatar
    3 posts
    Member since:
    Jul 2007

    Posted 29 Aug 2007 Link to this post

    Georgi,
       I have installed the new version of the MOSS control. I set AllowScripts to true in the configfile.xml and I set the AllowSpecialTags tag to true on my RadHtmlField in SharePoint Designer. (AllowSpecialTags does not appear to be a valid value in configfile.xml.)

    But it still seems to strip out Javascript.

    J
  4. J
    J avatar
    3 posts
    Member since:
    Jul 2007

    Posted 29 Aug 2007 Link to this post

    Georgi,
       Never mind, I see that my question has been answered in this thread:

    http://www.telerik.com/community/forums/thread/b311D-heckm.aspx

    The solution described there (using script tags) worked for me.

    Thanks,

    J
  5. Per Hoyer Stensnaes
    Per Hoyer Stensnaes avatar
    5 posts
    Member since:
    Sep 2009

    Posted 04 Sep 2009 Link to this post

    "Set (add if not present) the AllowScripts and AllowSpecialTags properties to true in ConfigFile.xml"
    AllowSpecialTags is not permittet in the configfile.xml - you should set that directly in the radE:RichHtmlField tag in the layoutpage - BUT it dosnt prevent the onclick, onmouseover etc from beeing stripped.
    as well there are A LOT of styling props that will be stripped fx.:
    <table style="background-image:url('/images/myPic.jpg');" will be stripped.
    ...
  6. Stanimir
    Admin
    Stanimir avatar
    1653 posts

    Posted 07 Sep 2009 Link to this post

    Hi Per,

    If you are using the latest version of RadEditor for MOSS, which is 5.5.1, in WCM scenario you need to set both AllowScripts and AllowSpecialTags properties to true in the current page using SharePoint Designer.
    For example:
    <telerik:RadHtmlField id="Content" AllowScripts="true" AllowSpecialTags="true" FieldName="PublishingPageContent"  runat="server"/> 

    Regarding this issue "BUT it dosnt prevent the onclick, onmouseover etc from beeing stripped.", this seems to be yet another problem, caused by the MOSS content filter. When you submit the page, MOSS will validate it and automatically make changes if the content is not valid. You can verify this by trying to enter the same content with the original SharePoint rich text editor. We have not been able to find a workaround for this behavior yet.

    Greetings,
    Stanimir
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
Back to Top