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

Anchors and Preview Mode

8 Answers 105 Views
Editor
This is a migrated thread and some comments may be shown as answers.
Dan Ehrmann
Top achievements
Rank 1
Dan Ehrmann asked on 15 Apr 2011, 11:57 PM
I have two problems with anchor tags. First, in preview mode, the full url of the current page is added, so rather than navigate to their targets, they try to open a new editor page. So, a tag like this:

<a href="#top">Return to Top</a>

opens a new window. I found a workaround for this. If you go to preview mode, then switch to html mode, and then back to preview mode, the anchor works properly. Without the back-and-forth, it opens a new window. I was able to reproduce this behavior in the editor demo.

Second, we had a case where the url of the editor page actually got added to the href of a number of anchor tags. I manually cleaned them up, and the problem did not recur (yet...). I can't reproduce it, but it is not the kind of thing a user could have done on purpose. I have asked the user for more info on how this may have happened, so I will post again if I hear anything interesting.

BTW - while researching this problem, I ran into this post (http://www.telerik.com/community/forums/aspnet-ajax/editor/editor-generates-target-and-re-target-properties-in-links.aspx) which discusses a 're-target' attribute being added to anchors. The anchors I cleaned up also had this attribute.

8 Answers, 1 is accepted

Sort by
0
Rumen
Telerik team
answered on 19 Apr 2011, 02:23 PM
Hi Dan,

Thank you for reporting this problem.

I reproduced it and logged it for fixing in our PITS system. Here you can find the PITS Issue: Public URL.

Until we solve the issue, you can use the following temporary fix:

<telerik:RadEditor ID="RadEditor1" runat="server"></telerik:RadEditor>
<script type="text/javascript">
    Telerik.Web.UI.Editor.Utils.setTargetsForPreview = function (editor) {
        var contentArea = editor.get_contentArea();
        var links = contentArea.getElementsByTagName("A");
        for (var i = 0, l = links.length; i < l; i++) {
            var link = links[i];
            var href = link.getAttribute("href", 2);
            if (!href.match(/^#/)) {
                if (link.getAttribute("re_target") == null) {
                    link.setAttribute("re_target", link.getAttribute("target"));
                    link.setAttribute("target", "_blank");
                }
            }
        }
    }
</script>

Best regards,
Rumen
the Telerik team

Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.

0
Dan Ehrmann
Top achievements
Rank 1
answered on 20 Apr 2011, 02:40 PM
Thanx Rumen, that worked.. I had to make one minor fix. I changed the line:

if (!href.match(/^#/)) {

to:
if ((href && (!href.match(/^#/))) {

0
Dan Ehrmann
Top achievements
Rank 1
answered on 26 Apr 2011, 08:48 PM
I am still having problems with this. In some cases, anchor tags in the preview window try to re-open a new copy of the page inside the editor, or reload the entire page. In Firefox, you can see this in the editor demo. Just add an anchor and a link to that anchor to the demo content. Then go to preview and click the link - the entire page reloads. With IE and Chrome, a new window is opened.

In my situation, I tested with IE and Chrome, and the script suggested by Rumen works. In Firefox, it does not - the current page (including the editor) loads within the editor (nested editors!).

I have a customer who reports problems in IE and Chrome, but I haven't been able to reproduce it yet.

Testing was done with Chrome 10, Firefox 4, and IE 8
0
Rumen
Telerik team
answered on 29 Apr 2011, 03:14 PM
Hello Dan,

I logged the Firefox problem in the same PITS item http://www.telerik.com/support/pits.aspx#/public/aspnet-ajax/5614 and our developers will further research it.

Best regards,
Rumen
the Telerik team

Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.

0
William
Top achievements
Rank 1
answered on 12 Oct 2011, 03:06 AM
Has this issue ever been fixed? I am using version 2011.2.915.40 and just ran into this issue.

I looked at the PITS and it showed it was for IE9 -- except, I ran into this with IE8.

<telerik:radeditor id="reContent" runat="server">
    <cssfiles>
        <telerik:editorcssfile value="../styles/styles.css" />
    </cssfiles>
</telerik:radeditor>
0
Rumen
Telerik team
answered on 14 Oct 2011, 01:02 PM
Hello William,

I tried to reproduce the problem in IE8 but without success. Could you please see my test in the following video http://screencast.com/t/YAAJzfeu and let me know if I am missing something?

Best wishes,
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
William
Top achievements
Rank 1
answered on 27 Aug 2012, 07:27 PM
I have the latest version of the controls 2012.2.724 and this issue is still occurring.

What I have determined is that if the end-user has the Preview tab selected and then submits the page to the server, the target= and re_target= links get added to the HTML.

This is the only way that I have been able to reproduce this issue.
0
Rumen
Telerik team
answered on 28 Aug 2012, 11:35 AM
Hi,

Since I am unable to replicate this problem, my suggestion is to attach to the OnClientSubmit event of RadEditor and strip the target= and re_target= links attributes when submitting the content.

Kind 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.
Tags
Editor
Asked by
Dan Ehrmann
Top achievements
Rank 1
Answers by
Rumen
Telerik team
Dan Ehrmann
Top achievements
Rank 1
William
Top achievements
Rank 1
Share this question
or