Anchors and Preview Mode

9 posts, 0 answers
  1. Dan Ehrmann
    Dan Ehrmann avatar
    166 posts
    Member since:
    Jul 2004

    Posted 15 Apr 2011 Link to this post

    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.
  2. Rumen
    Admin
    Rumen avatar
    14323 posts

    Posted 19 Apr 2011 Link to this post

    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.

  3. Dan Ehrmann
    Dan Ehrmann avatar
    166 posts
    Member since:
    Jul 2004

    Posted 20 Apr 2011 Link to this post

    Thanx Rumen, that worked.. I had to make one minor fix. I changed the line:

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

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

  4. Dan Ehrmann
    Dan Ehrmann avatar
    166 posts
    Member since:
    Jul 2004

    Posted 26 Apr 2011 Link to this post

    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
  5. Rumen
    Admin
    Rumen avatar
    14323 posts

    Posted 29 Apr 2011 Link to this post

    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.

  6. William
    William avatar
    4 posts
    Member since:
    Jul 2012

    Posted 11 Oct 2011 Link to this post

    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>
  7. Rumen
    Admin
    Rumen avatar
    14323 posts

    Posted 14 Oct 2011 Link to this post

    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
  8. William
    William avatar
    4 posts
    Member since:
    Jul 2012

    Posted 27 Aug 2012 Link to this post

    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.
  9. Rumen
    Admin
    Rumen avatar
    14323 posts

    Posted 28 Aug 2012 Link to this post

    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.
Back to Top