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

[Solved] InsertSpecialLink and selection of a link and normal

5 Answers 111 Views
Editor
This is a migrated thread and some comments may be shown as answers.
karn
Top achievements
Rank 1
karn asked on 10 Feb 2010, 12:59 PM
i test the example of InsertSpecialLink it is work fine exept when i select a normal text and a link i have this error js :

Message : Erreur d'exécution inconnue
Ligne : 147
Caractère : 14
Code : 0
URI : http://soliserv02/chart_test_export/editor2.aspx

 

how i fix that?

my code where ia have the error :

<script type="text/javascript">  
        //<![CDATA[  
        Telerik.Web.UI.Editor.CommandList["InsertSpecialLink"] = function(commandName, editor, args) {  
            var elem = editor.getSelectedElement(); //returns the selected element.  
 
            if (elem.tagName == "A") {  
                editor.selectElement(elem);  
                argument = elem;  
 
            }  
            else {  
 
                var content = editor.getSelectionHtml();  
 
                var link = editor.get_document().createElement("A");  
 
                // the error of selection
                link.innerHTML = content;  
          
                argument = link;  
       
            }  
        
            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))  
            }  
 
            editor.showExternalDialog(  
            'InsertLink.aspx',  
            argument,  
            270,  
            300,  
            myCallbackFunction,  
            null,  
            'Insert Link',  
            true,  
            Telerik.Web.UI.WindowBehaviors.Close + Telerik.Web.UI.WindowBehaviors.Move,  
            false,  
            true);  
        };  
 
 
          
        //]]>  
    </script> 

5 Answers, 1 is accepted

Sort by
0
karn
Top achievements
Rank 1
answered on 10 Feb 2010, 04:02 PM
the problem also exists on demo http://demos.telerik.com/aspnet-ajax/editor/examples/customdialogs/defaultcs.aspx

When i select "Built on top of ASP.NET AJAX " and clic on insert special link, i have a error.

Thank for you help
0
Dobromir
Telerik team
answered on 10 Feb 2010, 05:04 PM
Hi Jean-pierre,

From the error you have posted I noticed that you are using French version of the browser. Is it possible to test the site with En-US version of the browser and come back to us with the result.

Also could you please provide more details on the problem:
  • Which version of RadEditor you are using?
  • Which browser version you are using?

Best wishes,
Dobromir
the Telerik team

Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
Follow the status of features or bugs in PITS and vote for them to affect their priority.
0
karn
Top achievements
Rank 1
answered on 10 Feb 2010, 05:21 PM
hi,

i test with IE8 but i don't think i can test with english version? if you are a solution, i ok to test.

I just test with chrome(5.0.317.2) that work but the dialogs is it "broke"(capture)
With firefox(3.6) it is ok
With opera(10.10) the the dialogs is it "broke" and the insert drop a part of text selected
With IE6 same result with IE8

edit: i used trial version,downloaded yesterday
0
karn
Top achievements
Rank 1
answered on 11 Feb 2010, 10:32 AM

Hello,

have you any news?

thank!

0
Dobromir
Telerik team
answered on 12 Feb 2010, 05:35 PM
Hi Jean-Pierre,

This JavaScript error occurs because you are trying to insert a link tag inside another link tag. This is handled by the most of the browsers but unfortunately not by Internet Explorer so you need to handle it manually.

This problem can be avoided by excluding any link from the current selection before passing it to the newly created link element. You can use the following code to achieve this:
Telerik.Web.UI.Editor.CommandList["InsertSpecialLink"] = function(commandName, editor, args)
{
        //.....
    if (elem.tagName == "A")
    {
          //.....
    }
    else
    {
        var content = editor.getSelectionHtml();
                           //check for any links inside the selection and exclude if any
        if (content.indexOf("<A") > -1)
        {
            if ($telerik.isIE)
            {
                var newSelection = editor.getSelection().getRange();
                newSelection.moveEnd("character", - editor.getSelection().getText().length + content.indexOf("<A"));
                editor.getSelection().selectRange(newSelection);
            }
            content = content.substr(0, content.indexOf("<a"));
        }
        var link = editor.get_document().createElement("A");
 
        link.innerHTML = content;
        argument = link;
    }
        
        //.....
};

As a small token of our gratitude for bringing this problem to our attention I have updated your Telerik points.


Greetings,
Dobromir
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.
Tags
Editor
Asked by
karn
Top achievements
Rank 1
Answers by
karn
Top achievements
Rank 1
Dobromir
Telerik team
Share this question
or