New to Telerik UI for ASP.NET AJAXStart a free 30-day trial

Making Hyperlinks in RadEditor Open in a New Tab

Environment

ProductVersion
RadEditor for ASP.NET AJAXCurrent

Description

After adding a hyperlink in RadEditor and saving it, clicking the hyperlink does not open it in a separate tab; it tries to open in the same tab.

This KB article also answers the following questions:

  • How to make hyperlinks open in a new tab?
  • How to customize the Hyperlink Manager dialog in RadEditor?
  • How to use the OnClientDomChange event to modify hyperlink behavior in RadEditor?

Solution

To ensure that hyperlinks open in a new tab, you need to set the target attribute of the <a> tag to _blank. This can be achieved through the following solutions:

Customize the Hyperlink Manager dialog file (EditorDialogs/LinkManager.ascx). Utilize this demo as a base to proceed.

Solution 2: Use the OnClientDomChange Event

Attach to the OnClientDomChange event and modify the target attribute of the <a> tag inserted in the content area by the Hyperlink Manager:

javascript
<script type="text/javascript">
    function OnClientDomChange(editor, args) {
        
        var commandName = args.get_commandName();
        var value = args.get_value();
            
        if (commandName == "LinkManager") {
            var link = value;
            
            // Apply target="_blank" to the inserted link
            link.setAttribute("target", "_blank");
        }
    }
</script>
xml
<telerik:RadEditor runat="server" OnClientDomChange="OnClientDomChange" ID="RadEditor1"></telerik:RadEditor>

See Also