Changing forecolor for a link does not work on FF

3 posts, 0 answers
  1. Lakshman
    Lakshman avatar
    27 posts
    Member since:
    Jul 2012

    Posted 06 Apr 2009 Link to this post

    When a forecolor (for example, red color) is applied on a hyperlink, the forecolor changes on IE, whereas it does not on FF. I could reproduce this from your demo site as well.

    This is how the HTML gets created on both the browsers. Span tag is inside the anchor tag and therefore it works.

    IE:
    <a href="http://www.google.com"><span style="color: #c00000;">test</span></a>

    FF:
    <span style="color: #ff0000;"><a href="test">http://www.google.com">test</a></span>

    We would like to get this fixed for our customers and can you please give us a workaround?

    Thanks, Lakshman
  2. Lakshman
    Lakshman avatar
    27 posts
    Member since:
    Jul 2012

    Posted 06 Apr 2009 Link to this post

    Sorry, I mistyped the html for FF and here is the right one:

    <span style="color: #ff0000;"><a href="http://www.google.com">test</a></span>

    Thanks, Lakshman
  3. Rumen
    Admin
    Rumen avatar
    13899 posts

    Posted 09 Apr 2009 Link to this post

    Hi Lakshman,

    You can customize the ForeColor command using the code below:

    <telerik:RadEditor ID="RadEditor1" OnClientCommandExecuting="OnClientCommandExecuting" runat="server" >
    </telerik:RadEditor>
    <script type="text/javascript">
    function OnClientCommandExecuting(editor, args)
    {
       //The command name
       var commandName = args.get_commandName();  
          
       if (commandName == "ForeColor")
       {
           //The selected value [if command is coming from a dropdown]
           var color = args.get_value();          
          
           var selectedElem = editor.getSelectedElement();
           if (selectedElem.tagName == "A")
           {
               selectedElem.style.color = color;
               args.set_cancel(true); //cancel the original command
           }
       }
    }
    </script>

    Thus the ForeColor tool will apply an inline color style to the selected link tag.

    Best regards,
    Rumen
    the Telerik team

    Check out Telerik Trainer , the state of the art learning tool for Telerik products.
Back to Top