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

MakeUrlsAbsolute and IECleanAnchors

5 Answers 89 Views
Editor
This is a migrated thread and some comments may be shown as answers.
HSLaw
Top achievements
Rank 1
HSLaw asked on 17 Apr 2012, 03:32 AM
Hi,

I wonder if we can use MakeUrlsAbsolute and IECleanAnchors together?

In our CMS edit page that use the editor, we need to make all URL Absolute. e.g. www.test.com.my/page1.aspx
But when we set that filter, the Anchor will automatically have the path of the CMS edit page.

E.g. 
<A href="http://www.test.my/cms/content_editor.aspx?id=9f81dbc0-4491-4a65-af26-f52bd1c25596#sss">plugged </A>

We try to set IECleanAnchors as well but not working.

What is the correct way to make sure the URL is absolute but the anchor don;t embed the path of the CMS?

Thanks.

5 Answers, 1 is accepted

Sort by
0
HSLaw
Top achievements
Rank 1
answered on 17 Apr 2012, 07:25 AM
Hi,

I tried again and noticed it is actually not working if there are 2 querystrings and it is working with 1 querystring, as demonstrated here:

http://www.ximnet.com.my/upload/telerik_editor_anchor_problem.swf

Thanks.

0
Rumen
Telerik team
answered on 18 Apr 2012, 04:30 PM
Hello,

I am aware of this problem and it is already logged for fixing it in our PITS system. We will enhance the IECleanAnchorsFilter to strip absolute anchors with queries in the paths. Here you can find the PITS Issue: Public URL.

You can solve the problem with the following code:
<telerik:RadEditor runat="server" ID="RadEditor1" ContentFilters="DefaultFilters,MakeUrlsAbsolute"></telerik:RadEditor>
<script type="text/javascript">
    Telerik.Web.UI.Editor.IECleanAnchorsFilter.prototype.getHtmlContent = function (content) {
        var basePageUrl = Telerik.Web.UI.Editor.Utils.escapeRegExSpecialChars(document.location.href);
        basePageUrl = basePageUrl.replace(/:/ig, "\\:").replace(/&/ig, "&amp;");
        var re = new RegExp("(<A[^<>]*?(href)\\s*=\\s*['\"])(" + basePageUrl + ")(\\#[^'\"]*?['\"][^>]*?>)", "i");
        var newContent = content.replace(re, "$1$4");
 
        return newContent;
    }
</script>

Best regards,
Rumen
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
0
Dan Ehrmann
Top achievements
Rank 1
answered on 10 Oct 2012, 03:51 PM
Did this get fixed in a recent version? The PITS issue is not marked as being fixed, but the problem does not seem to occur in the demo anymore.
0
Misho
Telerik team
answered on 15 Oct 2012, 07:02 AM
Hello Dan,

Currently the issue is still not fixed. Note that in order to reproduce it you need to have 2 query strings in the URL. For the time being you could use the code provided by Rumen to workaround the problem.

All the best,
Misho
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
0
Dan Ehrmann
Top achievements
Rank 1
answered on 15 Oct 2012, 01:03 PM
ok - thanx. In my situation, we do have multiple items in the query string. I am using Rumen's code, and it works well.
Tags
Editor
Asked by
HSLaw
Top achievements
Rank 1
Answers by
HSLaw
Top achievements
Rank 1
Rumen
Telerik team
Dan Ehrmann
Top achievements
Rank 1
Misho
Telerik team
Share this question
or