This is a migrated thread and some comments may be shown as answers.

[Solved] Set target attribute of <a> tags

1 Answer 110 Views
Editor
This is a migrated thread and some comments may be shown as answers.
Markus
Top achievements
Rank 1
Markus asked on 02 May 2008, 11:37 AM
Hi,

whenever a user types in a url it gets automatically converted to a valid hyperlink. I like that. But additionally I want all these <a> tags to have the target-attribute set to "_blank".

Any suggestions?

1 Answer, 1 is accepted

Sort by
0
Markus
Top achievements
Rank 1
answered on 05 May 2008, 09:07 AM

Ok, I found it in the documentation:

    function OnClientLoad(editor, args)  
    {  
        editor.attachEventHandler("onkeyup", parseText);  
    }      
      
    function parseText()  
    {  
        var editor = $find("<%=RadEditor.ClientID %>");  
          
       var links = editor.get_document().getElementsByTagName("A");  
       for (var i = 0; i < links.length; i++)  
       {  
           var link = links[i];  
           link.setAttribute("target""_blank");  
       };  
    } 

<telerik:RadEditor ID="RadEditor" runat="server" OnClientLoad="OnClientLoad">  
</telerik:RadEditor> 
Tags
Editor
Asked by
Markus
Top achievements
Rank 1
Answers by
Markus
Top achievements
Rank 1
Share this question
or