
I have an editor in RAD window, and i want to insert a hyperlink into it content to open another window, with video. So i made a function OpenVideo() on a page where editor resides, and inserted following hyperlink into editor content:
this is test <a href="#" onclick="return OpenVideo('Video1');">video link</a>,
But when i click it - i get error object not found. Is it possible to make such hyperlink in editor content so i can run jscipt function on editor's page?
Thanks!
Alex
6 Answers, 1 is accepted
Hi Alex,
The reported error pops up because the editor's content area is an IFRAME which is another document and the javascript OpenVideo function is placed on the parent page. So the onclick event of the A tag cannot locate the OpenVideo function in the editor's content area and the js engine throws the error when you click on the image.
In order to achieve your scenario you should use the solution below that imports the external js code in the editor's content area:
<asp:ScriptManager ID="ScriptManager1" runat="server" />
<script id="PageJavaScript" language="javascript" type=text/javascript>
function test1()
{
alert("test");
}
</script>
<script type="text/javascript">
function OnClientLoad(editor, args)
{
var encodeScriptsFilter = editor.get_filtersManager().getFilterByName("EncodeScriptsFilter");
editor.get_filtersManager().remove(encodeScriptsFilter);
var oPageScript = document.getElementById("PageJavaScript");
var oScript = "<script defer='false'>\n" + oPageScript.innerHTML + "\n</" + "script>";
editor.setFocus();
editor.set_html(editor.get_html(true) + oScript);
}
</script>
<telerik:RadEditor ID="RadEditor1" OnClientLoad="OnClientLoad" runat="server">
<Content>
<img onclick="test1();" src="http://www.telerik.com/r.a.d.controls/Editor/Img/productBox.gif">
</Content>
</telerik:RadEditor>
Regards,
the Telerik team
Check out Telerik Trainer , the state of the art learning tool for Telerik products.

I cannot make your sample working, pasted in on new web form, but still get Object expected error. Can you check at your side?
Furthermore - in my application editor is place in rad window, and in my function i need to get access to GetRadWindow(), to open apropriate window then, will it work in your approach?
Thanks
Alex
By default the editor remove the script tags in the content area to prevent malicious scripts. In this scenario you should disable this client-side filter by setting the following server method in the codebehind:
RadEditor1.DisableFilter(Telerik.Web.UI.EditorFilters.RemoveScripts);
Please, note however that the content area of RadEditor is another document and when you display the produced by RadEditor content outside it then most likely the javascript code will not work. We do not support your scenario because the editor is intended to be used as HTML / XHTML editor.
Best regards,
Rumen
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 the same problem, did you solve it without implemeting Rumen's solution?
You mentioned you solved the javascript problem by creating a new "view". Hope you can kindly explain how you solved this issue, since the editor's content area is on an iframe.
I would like to have a solution that will still restrict users from entering malicious javascript code from the HTML mode.
Thanks,
Henry Wu

i have added asp liter control on the same page, so for edit mode i show rad editor and and view mode - i hide editor and fill literal with html cod from editor. now in view mode i can all jscript functions of the page
Alex