40 Answers, 1 is accepted
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
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> |
<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> |
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
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
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:
- set the AllowScripts property to true in ConfigFile.xml and AllowSpecialTags = true in the the current page using SharePoint Designer
- Do not add your Javascript in the OnClick property. You must add it in a separate <script> block.
- Add an ID to your link
- 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
Thanks,
John W.
Spartanburg, SC
I don't see the spiffy movie. It would be helpful.
Thanks
Bob.
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>
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
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
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
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
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.
Thank you
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
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.
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
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.
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
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.
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.
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.
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
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.
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
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 before the <script> tag.
editor.pasteHtml(' <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.
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
Unfortunately this is again browser behavior of MS Internet Explorer. I tested the issue in FireFox and the javascript worked fine. Unfortunately currently we do not know of any workarounds for this. We will inform you if we find a fix for this.
Sincerely yours,
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.
I am using radEditor version 5.5.0.0.
I have activated the radEditor feature for using it in Sharepoint lists as well.
But in lists fields, it strips the script tag.
I have set "AllowScripts" property true in both ConfigFile.xml and ListConfigFile.xml.
Am I missing something to render script tags in list field?
Regards,
Archana
You cannot use Javascript in RadEditor in SharePoint forms scenario (Lists, Wikis, Blogs, etc.). 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.
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.
public class WERCRichTextFieldControl : BaseFieldControl
{
private MOSSRadEditor editCtrl;
protected TextBox ScriptTextBox;
protected Literal litMsg;
protected PlaceHolder EditorPlaceHolder;
protected override string DefaultTemplateName
{
get
{
return "WERCRichTextField";
//return base.DefaultTemplateName;
}
}
protected override void RenderFieldForDisplay(HtmlTextWriter output)
{
RenderChildren(output);
}
protected override void CreateChildControls()
{
if (this.Field == null || this.ControlMode == SPControlMode.Display || this.ControlMode == SPControlMode.Invalid)
return;
base.CreateChildControls();
if (ControlMode == SPControlMode.Edit || ControlMode == SPControlMode.New)
{
ScriptTextBox = (TextBox)TemplateContainer.FindControl("ScriptTextBox");
litMsg = (Literal)TemplateContainer.FindControl("litMsg");
EditorPlaceHolder = (PlaceHolder)TemplateContainer.FindControl("EditorPlaceHolder");
editCtrl = new MOSSRadEditor();
editCtrl.AllowScripts = true;
//--also added allowscripts in both the ListConfigFile.xml
//--and ConfigFile.xml
EditorPlaceHolder.Controls.Add(editCtrl);
if (!this.Web.CurrentUser.IsSiteAdmin)
{
ScriptTextBox.Visible = false;
ScriptTextBox.ReadOnly = true;
litMsg.Text = "Only Site Administrators can add Script<
br
/>";
}
}
}
public override object Value
{
get
{
EnsureChildControls();
//---see right here if I were using the ScriptTextBox
//---it has no problem saving anything that I plug in and the
//---base MultiLineTextField type is not stripping html content
//return ScriptTextBox.Text;
return editCtrl.Content;
}
set
{
EnsureChildControls();
base.Value = value;
ScriptTextBox.Text = value.ToString();
editCtrl.Content = value.ToString();
}
}
}
Thank you for the provided information, how ever the way your control is written I do not think that it will support SharePoint's automated features, such as automatic update of reusable content or automatic update of links etc. The price of supporting this features is that the content is modified by the SharePoint content filters which strip a lot of "invalid" (according to them) code.
Sincerely yours,
Stanimir
the Telerik team
Check out Telerik Trainer, the state of the art learning tool for Telerik products.
I need to get the special characters into a rich text field. I know I can do it if I create a custom field type based on the same type the OOTB rich text box uses and just use my own asp.net textbox as shown from the previous post. That doesn't work though with the MOSSRadEditor. Maybe the answer here is that I have to use the basic radeditor and not the MOSSRadEditor? How exactly does the MOSSRadEditor tie into the sharepoint libraries? Does it call internal sharepoint stuff before the .content of the MOSSRadEditor is handed back?
Does it call internal sharepoint stuff before the .content of the MOSSRadEditor is handed back? - Yes RadEditor uses SharePoint API in order to display and save the content. If you open an official support ticket and you have valid license information I will provide you with the source code of the control and you will be able to see the exact implementation.
Greetings,
Stanimir
the Telerik team
Check out Telerik Trainer, the state of the art learning tool for Telerik products.
If I were to use the regular radeditor vs. the sharepoint version what major losses would I have in functionality?
Or would it be better to like you said take the source code for the MOSSRadEditor and rewrite it so that it doesn't leverage the sharepoint stripping engine before it inserts its value into the field? Or do you guys already have a version or hotfix like that? It just sounds like not everyone cares to allow sharepoint to strip the potentially bad code blocks. It seems like it would be an easy enough thing to set up as a configurable choice for MOSSRadEditor.
If you use the regular ASP.NET AJAX RadEditor, you will loose the filebrowser based dialogs, such as ImageManager, DocumentManager etc. In RadEditor for MOSS there is a specially designed content provider, which works with SharePoint libraries.
Regards,
Stanimir
the Telerik team
Check out Telerik Trainer, the state of the art learning tool for Telerik products.
If so how do I point to those?
Actually these are the same dialogs the think that is different is the content provider, which is embedded in the MOSS RadEditor. Review the following blog post: Using the RadFileExplorer for ASP.NET AJAX in a MOSS web application. Also review the following online demo: Editor / Custom File Dialogs Content Provider
Sincerely yours,
Stanimir
the Telerik team
Check out Telerik Trainer, the state of the art learning tool for Telerik products.