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

XHTML Strict - Using "rel" instead of "target" in anchors

2 Answers 120 Views
Editor
This is a migrated thread and some comments may be shown as answers.
Darren
Top achievements
Rank 1
Darren asked on 16 Apr 2010, 06:30 PM
Greetings,

XHTML Strict does not allow the "target" attribute inside of an anchor. Instead, I have used rel="external" combined with some javascript when trying to open links in a new window. I would like to modify the default link manager to do this. So, instead of being able to select a "target" in the link manager, I would like to choose a value for "rel".

I was able to successfully customize the link manager by route of the ExternalDialogsPath property in the radEditor so that the drop down menu values are correct. However, I am unable to figure out how to override the callback function when the anchor is pasted back into the editor. When inserting an anchor into the radEditor, I would like to change the default of "target":
var myCallbackFunction = function(sender, args) {  
      editor.pasteHtml(String.format("<a href={0} target='{1}' class='{2}'>{3}</a> ", args.href, args.target, args.className, args.name)); 
      //---------------------------------------------^ 
 
to "rel":
var myCallbackFunction = function(sender, args) {  
      editor.pasteHtml(String.format("<a href={0} rel='{1}' class='{2}'>{3}</a> ", args.href, args.target, args.className, args.name)); 
      //-------------------------------------------^ 

I am sure I am overlooking something simple but cannot find a solution online.

Thank you in advance for any help.
Darren

2 Answers, 1 is accepted

Sort by
0
Accepted
Rumen
Telerik team
answered on 20 Apr 2010, 02:53 PM
Hi Darren,

There are two ways to modify the content returned by the Link manager dialog:

1) To override the set_callbackFunction:

<telerik:RadEditor ID="RadEditor1" runat="server" OnClientCommandExecuting="OnClientCommandExecuting"></telerik:RadEditor>
  
<script type="text/javascript">
    function OnClientCommandExecuting(sender, args) {
        var commandName = args.get_commandName();
        if (commandName == "LinkManager")
            args.set_callbackFunction(function(sender, args) {
                //this is the current output of the MediaManager
                var output = args.get_value();
                alert(output);
                //add some modifications to the output
 
            })
    }
</script>

2) or to attach to the OnClientPasteHtml event, check for the LinkManager command and modify the value returned by the args.set_value() method.


Kind regards,
Rumen
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
0
Darren
Top achievements
Rank 1
answered on 20 Apr 2010, 07:13 PM
Thank you Rumen.
Tags
Editor
Asked by
Darren
Top achievements
Rank 1
Answers by
Rumen
Telerik team
Darren
Top achievements
Rank 1
Share this question
or