Javascript in MOSS radEditor

41 posts, 1 answers
  1. John Way
    John Way avatar
    16 posts
    Member since:
    Mar 2005

    Posted 09 Aug 2007 Link to this post

    Is there a work-around or configuration setting to allow the follwoing in the MOSS Premium radEditor
    • inline javascript and / or onClick events that call javascript in the
    • style commands on DIV's
    • iframes

    Thanks,

    John

  2. Georgi Tunev
    Admin
    Georgi Tunev avatar
    7207 posts

    Posted 09 Aug 2007 Link to this post

    Hi John,

    I am not quite sure what exactly you want to achieve, however you can use Javascript in RadEditor's content are in certain scenarios only. To enable Javascript, you need to do the following:

    • 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.



    Best wishes,
    Georgi Tunev
    the Telerik team

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

  3. John Way
    John Way avatar
    16 posts
    Member since:
    Mar 2005

    Posted 09 Aug 2007 Link to this post

    The changes you recommended did not work. For my current task, I am trying to create an inline, sized, javascript  popUp Window in a WCM radEditor field control.
    I already had the AllowSpecialTags attribute set to true in the Page Layout's radE:RadHtmlField control to allow flash content. That was working fine. I added both tags to the config.xml anyway, per your instructions, and received a runtime error.
    Configuration File provided is not valid. Invalid entries: AllowSpecialTags
    I removed the AllowSpecialTags property from the config.xml and the error went away. However, when I try to add a javascipt call using the radEditor, the content gets stripped when I publish the page.

    <a href="#" OnClick="window.open('http://www.google.com', 'Google'', 'height=130, width=160', false); return false;">Google</a>  
     
    get changed to
    <a href="#">Google</a>  

    I also tried adding the AllowScripts to the radE:radHtmlField control, but that was not allowed either.

    Here is my config.xml code:
    <?xml version="1.0" encoding="utf-8" ?> 
    <!-- ==============================================================================================  
        Config File valid structure:  
        <configuration> 
        <property>...</property> 
        ...  
            <property> 
                <item>...</item> 
                <item>...</item> 
                ...  
            </property> 
            ...  
        </configuration> 
    =============================================================================================== --> 
    <configuration> 
      <property name="AllowScripts">True</property> 
      <property name="AllowThumbGeneration">True</property> 
      <property name="ConvertToXhtml">True</property> 
      <property name="EnableDocking">False</property> 
      <property name="ShowHtmlMode">True</property> 
      <property name="ShowPreviewMode">False</property> 
      <property name="StripAbsoluteAnchorPaths">False</property> 
      <property name="StripAbsoluteImagesPaths">False</property> 
      <property name="ToolbarMode">ShowOnFocus</property> 
      <property name="ToolsWidth">800px</property> 
    </configuration> 
  4. Georgi Tunev
    Admin
    Georgi Tunev avatar
    7207 posts

    Posted 09 Aug 2007 Link to this post

    Hello John,

    I would like to apologize for misleading you in my previous reply. You need to set the AllowScripts property to true in ConfigFile.xml and AllowSpecialTags = true in the the current page using SharePoint Designer - AllowSpecialTags cannot be set via ConfigFile.xml.

    Once again, sorry for the trouble.



    Greetings,
    Georgi Tunev
    the Telerik team

    Instantly find answers to your questions at the new Telerik Support Center
  5. John Way
    John Way avatar
    16 posts
    Member since:
    Mar 2005

    Posted 09 Aug 2007 Link to this post

    No problem, however...
    After making the changes, I still can't add javascript or onClick calls. The script is still getting stripped. (see my last post for details)

    Is there something else I'm missing?

    Thanks,
    John
  6. Answer
    Georgi Tunev
    Admin
    Georgi Tunev avatar
    7207 posts

    Posted 10 Aug 2007 Link to this post

    Hello John,

    We (me and one of our RadEditor for MOSS developers) checked your code and it occurs that it must be inserted in a little bit of different way than the one you are using. The procedure is a little cumbersome and we will do our best to improve the situation in one of the following updates. Unfortunately at this point it must be followed step-by-step as otherwise the MOSS itself will clear the Javascript.

    Here is how to add your Javascript step-by-step:
    1. set the AllowScripts property to true in ConfigFile.xml and AllowSpecialTags = true in the the current page using SharePoint Designer
    2. Do not add your Javascript in the OnClick property. You must add it in a separate <script> block.
    3. Add an ID to your link
    4. After the link's declaration, add a <script></script> block with the needed Javascript, e.g: document.getElementById('yourID').onclick=function (){yourFunction};

    Note that the <script> block must be placed on a single line - do not press Enter, otherwise the MOSS will remove the script tags.

    For convenience I've attached to this thread a small movie that shows how to insert your code in RadEditor for MOSS.
    Let me know if you experience any problems with the approach.




    All the best,
    Georgi Tunev
    the Telerik team

    Instantly find answers to your questions at the new Telerik Support Center
  7. John Way
    John Way avatar
    16 posts
    Member since:
    Mar 2005

    Posted 10 Aug 2007 Link to this post

    A video that walks me through the solution?? You Guys ROCK! Finally a company that actually lives by their slogan. This truly was "more than expected".

    Thanks,
    John W.
    Spartanburg, SC
  8. Bob
    Bob avatar
    9 posts
    Member since:
    Oct 2007

    Posted 05 Feb 2008 Link to this post

    Hi,

    I don't see the spiffy movie.  It would be helpful.

    Thanks

    Bob.
  9. John Way
    John Way avatar
    16 posts
    Member since:
    Mar 2005

    Posted 05 Feb 2008 Link to this post

    It's in the thread above. It's called MossJavascript.zip
  10. Bob
    Bob avatar
    9 posts
    Member since:
    Oct 2007

    Posted 06 Feb 2008 Link to this post

    duh...

    Thanks - I was having a slow day.

    In essence...
    <a id="PrintIt" href="#">
        Where Am I 
    </a>
    <script type="text/javascript">document.getElementById('PrintIt').onclick=function(){alert('I Is Here')};</script>

  11. John Wilson
    John Wilson avatar
    1 posts
    Member since:
    Mar 2008

    Posted 04 Jun 2008 Link to this post

    Jon,

    I have the same issue using vs. 4.5.3 of the Rad Editor for MOSS.  Do  I still need to use the same work around?  Has this changed in v. 5.0.0?

    Thanks,

    John Wilson
  12. Lini
    Admin
    Lini avatar
    2144 posts

    Posted 04 Jun 2008 Link to this post

    Hi John,

    Yes, you still need to use this workaround in version 5.0. As we said previously, the problem is actually in a MOSS content filter and not the editor itself. The only way to have scripts in the content is to encode them before the content is saved in the SharePoint field. This way the script will not be stripped. I don't think that we will be able to fix this in a future editor release.

    Sincerely yours,
    Lini
    the Telerik team

    Instantly find answers to your questions at the new Telerik Support Center
  13. Dave
    Dave avatar
    1 posts
    Member since:
    Jul 2008

    Posted 20 Jul 2008 Link to this post


  14. laks
    laks avatar
    6 posts
    Member since:
    Nov 2008

    Posted 08 May 2009 Link to this post

    I am trying the trial version.
    I have done exactly as in the video and have taken care of the other installation instructions.
    I am however loosing the javascript the moment I checkin or publish the page.
    The javascript seems to be persistent as long as I toggle betweent he design,html and presentation  views
    Any thing else that needs to be done to get the javascript to persist in the published version..

    Thank you
  15. Thiyagarajan
    Thiyagarajan avatar
    2 posts
    Member since:
    May 2009

    Posted 11 May 2009 Link to this post

    Hi,

             I am facing the same issues.
           
              Iam using Rad Editor 4.5.3.2 for my Organisation. When i save my content with Javascript , the savascript is stripped.
              I tried all the possible way given by you but it doesnt work .

              I cant include the script pag by page since mine is a MOSS application.


              I kindly request you to help me to get rid of this issue.


              My Contact :  +91 9916149227

    Thanks and Regards

    Thyagu

     

           

  16. Stanimir
    Admin
    Stanimir avatar
    1653 posts

    Posted 11 May 2009 Link to this post

    Hello Thiyagarajan,

    Could you please confirm that you are not using the RadEditor for MOSS in form scenario such as List, Wiki, Blog? If this is the case you should know that after sending the content to the SharePoint server some content filters are applied and they are stripping the javascript tags. Unfortunately RadEditor has no control over these filters.


    Kind regards,
    Stanimir
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Check out the tips for optimizing your support resource searches.
  17. laks
    laks avatar
    6 posts
    Member since:
    Nov 2008

    Posted 11 May 2009 Link to this post

    Hi Stanmir,
    Is it becuase I am using a trial version to evaluate, that I am not getting a response! :)
    Just an FYI - I am not using the lists or wikis in MOSS.
    I am using the RadEditor for MOSS, just like displayed in the video...
    The script gets stripped...
    It is a simple test trying to replace the HTML Placeholder with RadEditor..
    Look forward to hearing for some resolution! :)

    Thank you
    laks

  18. Thiyagarajan
    Thiyagarajan avatar
    2 posts
    Member since:
    May 2009

    Posted 12 May 2009 Link to this post

    Hi,



                            Thank you for your quik response.
                            Iam using the Rad in Wiki and Create Page.        These are the Places it gets stripped.
                              If this is Stripped by MOSS. Do you have any info how i can over come the same.

     

    regards

    Thyagu

  19. Stanimir
    Admin
    Stanimir avatar
    1653 posts

    Posted 13 May 2009 Link to this post

    Hi Thiyagarajan,

    Unfortunately in this moment we do not know of existing work around. This is MOSS issue and it is not related to the RadEditor for MOSS control.

    Greetings,
    Stanimir
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Check out the tips for optimizing your support resource searches.
  20. Shishir
    Shishir avatar
    3 posts
    Member since:
    Jun 2009

    Posted 08 Jun 2009 Link to this post

    Hi,

    I am trying to enable javascript support like you said by setting "AllowSpecialTags" to be true in telerik:RadHtmlField control in layout page and adding AllowScripts in configfile.xml. I am using RAD MOSS Editor v 5.2.1. I type the javascript in a single line and still it gets stripped on saving the page. 

    Pagelayout
                       <telerik:RadHtmlField FieldName="PublishingPageContent" runat="server" AllowSpecialTags="true" />

    configfile.xml in C:\Program Files\Common Files\Microsoft Shared\web server extensions\wpresources\RadEditorSharePoint\5.4.1.0__1f131a624888eeed\Resources
    <configuration>
     <property name="ToolbarMode">ShowOnFocus</property>
     <property name="ToolsWidth">680px</property> 
            <property name="AllowScripts">true</property>
    </configuration>

    Regards,
    Shishir 

  21. Lini
    Admin
    Lini avatar
    2144 posts

    Posted 08 Jun 2009 Link to this post

    Hi Shishir,

    Is your script in a <script> tag or inline (e.g. in a href or onclick attribute of an anchor)? Please make sure that all scripts are in a <script> tag. If possible, show us a sample of your content before/after the script is stripped.

    Sincerely yours,
    Lini
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Check out the tips for optimizing your support resource searches.
  22. Shishir
    Shishir avatar
    3 posts
    Member since:
    Jun 2009

    Posted 08 Jun 2009 Link to this post

    Hi Lini,

    Here is the code I am trying to save

    Test Scripts
    <script> alert('hello');</script>

    Once I publish, the content changes to just

    Test Scripts

    I have changed the AllowScripts property in configfile.xml and the AllowSpecialTags attribute in layout page rad editor control to true.

    Shishir

  23. Stanimir
    Admin
    Stanimir avatar
    1653 posts

    Posted 08 Jun 2009 Link to this post

    Hello Shishir,

    What you should know is that you can see the code that is sent to the MOSS site when you toggle between Design and HTML mode. Could you confirm that your javascript is executed when you toggle between modes?

    Also when you save the content to the MOSS site some SharePoint's filters are applied over it. These filters are responsible for stripping the javascript code. Unfortunately RadEditor can not control this SharePoint functionality and there is no known work around for it.


    Kind regards,
    Stanimir
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Check out the tips for optimizing your support resource searches.
  24. Shishir
    Shishir avatar
    3 posts
    Member since:
    Jun 2009

    Posted 08 Jun 2009 Link to this post

    Hi Stanimir, 

    When I switch between design and code mode I still see the script code. However the code is not executed. I can switch multiple times without loosing the script. Only once I publish it or check it  in the script tag is stripped. The tag and code are completely in one line.

    Why I ask is because some people on this site seem to have been able to save script changes. Like the video you shared shows the saving working but when I tried exact same code it did not work on my SharePoint server. I am also using publishing template.

  25. Stanimir
    Admin
    Stanimir avatar
    1653 posts

    Posted 08 Jun 2009 Link to this post

    Hello Shishir,

    The javascript is not executed because there is a content filter, provided by Telerik, which stops the javascript from executing. How ever if you can see the javascript code in Html mode this means that it is sent to the server and is stripped on it. Again RadEditor has no control over this.


    Regards,
    Stanimir
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Check out the tips for optimizing your support resource searches.
  26. Archana
    Archana avatar
    18 posts
    Member since:
    May 2009

    Posted 04 Jul 2009 Link to this post

    Hi Stanimir

    I have recently upgraded my radEditor for MOSS from 5.4.0.0 to 5.4.1.0.
    But I am facing the issue with script tag added for the html link as following.
    The tags which i am adding through a button is :
        <div><a href="/links/redirectlink.aspx?id=yahoo mail.aspx" class="new-window-left" id="47200917594425" title="yahoo mail" target="_blank">yahoo mail</a>
    <script>document.getElementById("47200917594425").onclick=function(){ExnLinkTrack(this);}</script>
    </div>

    The problem is : While checking in the page from html view of radEditor the script tag is retained on editing the page next time,  but while checking in the page from design view of radEditor the script tag gets stripped off on editing the page next time.

    Please note that i have set both the properties - "AllowScripts" in configFile and "AllowSpecialTags" in page as true.

    I was not facing the same problem with version 5.4.0.0.

    Is there any solution for this?

    Regards,
    Archana

  27. Stanimir
    Admin
    Stanimir avatar
    1653 posts

    Posted 07 Jul 2009 Link to this post

    Hi Archana,

    This week we will release the new version of RadEditor for MOSS 5.5.0. The issue will be fixed in it. You can find upgrade instructions in the following help article http://www.telerik.com/help/aspnet-ajax/upgrade_to_a_newer_version_of_radeditor_for_moss.html.

    Also keep in mind that you can not enter javascript in form scenarios, such as list, wiki, blog ... .  Here is the help article that describes the usage of scripts in RadEditor http://www.telerik.com/help/aspnet-ajax/scripts-in-radeditor.html


    All the best,
    Stanimir
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Check out the tips for optimizing your support resource searches.
  28. Archana
    Archana avatar
    18 posts
    Member since:
    May 2009

    Posted 07 Jul 2009 Link to this post

    Hi Stanimir,

     

    Thanks for the prompt reply.

    However there is one more issue i am encountering for the version 5.4.1.0: 
     I have added a custom button in radEditor toolbar.
    On click of that button I want a script to be generated and pasted in the html view.
    Say for e.g. 

        <script>
        var strTitle="Title";
        alert(strTitle);
        </script>

    In the function for that custom button in MossEditorTools.js file, i am writing following code :
        editor.pasteHtml('<script>var strTitle="Title";alert(strTitle);</script>')

    But on switching to html mode it does not show the script tag at all, i.e. if i modify the code as 
        editor.pasteHtml('<div><script>var strTitle="Title";alert(strTitle);</script></div>')
    then in html view it will only show : <div></div>
    The script tag is totally stripped.

    Please not that i have set both the properties : "AllowScript" in ConfigFile and "AllowSpecialTags" in page as true.
    Any clue on how to address this ?

    Regards,
    Archana

  29. Stanimir
    Admin
    Stanimir avatar
    1653 posts

    Posted 09 Jul 2009 Link to this post

    Hi Archana,

    The described issue is a known Internet Explorer browser behavior. I can suggest you the following work around. what you need to do is add a &nbsp; before the <script> tag.
    editor.pasteHtml('&nbsp;<script>var strTitle="Title";alert(strTitle);</script>'); 

    I hope this helps.



    All the best,
    Stanimir
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Check out the tips for optimizing your support resource searches.
  30. Archana
    Archana avatar
    18 posts
    Member since:
    May 2009

    Posted 10 Jul 2009 Link to this post

    Hi Stanimir,

    Thanks a lot. It worked for me.
    However, in js file i have written code for the button to copy following text in htmlview :
        <script type="text/javascript"> var strEmail1="abc_xyz";var strEmail2="@";var strEmail3="def.com";var strTitle="Archana Kanth";document.write("<a href=mailto:"+ strEmail1 + strEmail2 + strEmail3 + ">" + strTitle + "</a>");</script>

    But instead its copying following text in the html view on clicking that button :
        <script type="text/javascript"> var strEmail1="abc_xyz";var strEmail2="@";var strEmail3="def.com";var strTitle="Archana Kanth";document.write("<a href=mailto:" originalAttribute="href" originalPath="mailto:"" + strEmail1 + strEmail2 + strEmail3 + ">" + strTitle + "</a>");</script>

    The text in the bold is appended by itself in the script tag and this is creating problem in the page.

    Any solution to avoid the appending text in the script?

    Regards,
    Archana
Back to Top