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

makeurlsabsolute adn email anchors

6 Answers 48 Views
Editor
This is a migrated thread and some comments may be shown as answers.
rdochert
Top achievements
Rank 1
rdochert asked on 05 Nov 2008, 08:30 PM
i'm using the makeurlsabsolute content filter to convert urls and it is working fine. however, i have found that the content filter is converting anchor links which, it seems to me, it should not. any hyperlink which begins with a # should not have the URL modified in any way since the # specifically points to the current document.

whilst it would probably be ok for anchor tags within normal web pages, it is an insurmountable issue for editing the content of emails - which frequently include the use of anchors to skip up and down the email content.

can you advise how i can overcome this?

sincerely,
rob

6 Answers, 1 is accepted

Sort by
0
Stanimir
Telerik team
answered on 10 Nov 2008, 02:26 PM
Hello rdochert,
Thank you for suggestion on that how the MakeUrlsAbsolute content filter should handle anchors. We will consider for our future releases. For now I can advise you to create your own custom filter that will handle the anchors. You can find out how to implement a custom filter in our online help http://www.telerik.com/help/aspnet-ajax/contentfilters.html

Here is a sample code that you can use:

    <script type="text/javascript"
        function OnClientLoad(editor, args) 
        { 
            editor.get_filtersManager().add(new MyFilter()); 
        } 
        MyFilter = function() 
        { 
            MyFilter.initializeBase(this); 
            this.set_isDom(true); 
            this.set_enabled(true); 
            this.set_name("RadEditor filter"); 
            this.set_description("RadEditor filter description"); 
        } 
        MyFilter.prototype = 
        { 
            getHtmlContent : function(content) 
            {                                   
                var newContent = content;                 
                var tags = newContent.getElementsByTagName("A"); 
                var length = tags.length;                     
                for(i = 0; i < length; i++) 
                { 
                    var link = tags[i]; 
                    var href = link.href; 
                    if(href.lastIndexOf("#") != -1){ 
                        link.href = href.substr(href.lastIndexOf("#"));                         
                    }                     
                }                                 
                return newContent; 
            }, 
 
            getDesignContent : function(content) 
            { 
                var newContent = content
                //Make changes to the content and return it                 
                return newContent; 
            } 
        }         
        MyFilter.registerClass('MyFilter', Telerik.Web.UI.Editor.Filter); 
        </script> 
        <telerik:radeditor runat="server" ID="RadEditor1" Height="600" ExternalDialogsPath="EditorDialogs" OnClientLoad="OnClientLoad" ContentFilters="MakeUrlsAbsolute">             
            <Content>                     
                <href="#test">test</a>                
            </Content>               
        </telerik:radeditor> 





Greetings,
Stanimir
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
Stanimir
Telerik team
answered on 12 Nov 2008, 01:40 PM
Hi Rob,

You can use IECleanAnchors content filter to convert anchor links as well.

All the best,
Stanimir
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
rdochert
Top achievements
Rank 1
answered on 12 Nov 2008, 02:52 PM
hi - thanks for that suggestion. it works well except for one problem i found with the filter.
if the page that the filter is working on has a querystring parameter then the filter does not remove the url.

so, if you place the editor on page:
http://mysite.com/edit.aspx

with filters:

RadEditor1.EnableFilter(Telerik.Web.UI.EditorFilters.MakeUrlsAbsolute)

RadEditor1.EnableFilter(Telerik.Web.UI.EditorFilters.IECleanAnchors)


it works perfectly.
however, if you call the editing page like this:
http://mysite.com/edit.aspx?id=101

then the URLs are not removed and the anchors are corrupted.
is there any possiblity of a fix for that?

thanks,
rob
0
rdochert
Top achievements
Rank 1
answered on 17 Nov 2008, 01:50 AM
hi - any update on this? it does seem quite clearly like a bug in the filter to me.
thanks,
rob
0
rdochert
Top achievements
Rank 1
answered on 19 Nov 2008, 10:12 AM
Still waiting on a reply. Would really appreciate someone having a look at this. it does, on the surface of it, appear to be a bug in the filter.
cheers,
rob

0
Lini
Telerik team
answered on 21 Nov 2008, 04:55 PM
Hi Rob,

Indeed this is a bug in the clean anchors filter. We have already fixed it and the fix will be included in next week's RadControls service pack release. I apologize for the inconvenience this has caused you.

If you do not wish to update your project with the new release, I can send you a JS workaround you can include on your page that will take care of the anchors in the editor.

All the best,
Lini
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
Tags
Editor
Asked by
rdochert
Top achievements
Rank 1
Answers by
Stanimir
Telerik team
rdochert
Top achievements
Rank 1
Lini
Telerik team
Share this question
or