Open Link in a New Window When Clicked | RadEditor for ASP.NET AJAX Documentation
Edit this page

Open Link in a New Window When Clicked

The code below demonstrates how to iterate RadEditor document links when the editor is loaded. The code sets the link target attribute to so that the link is opened in a new window when clicked. You can use this approach to modify the attributes and events of all HTML elements in the editor content area. This example opens the editor in Preview EditorMode so that clicking the links will have the expected behavior.

<script type="text/javascript">
    function OnClientLoad(editor)
        var links = editor.get_document().getElementsByTagName("A");
        for (var i = 0; i < links.length; i++)
            var link = links[i];
            link.setAttribute("target", "#");
<telerik:RadEditor RenderMode="Lightweight" ID="RadEditor1" runat="server" Skin="Default" OnClientLoad="OnClientLoad"
        Sample Content        
        <a href=";></a>
        <a href=""></a>
        <a href="">some.pdf</a>
Is this article helpful? No Yes
Thank you for your feedback!

Give article feedback

Tell us how we can improve this article