Links in preview mode dont open anymore

3 posts, 0 answers
  1. Yeroon
    Yeroon avatar
    87 posts
    Member since:
    Oct 2012

    Posted 05 Oct 2012 Link to this post


    Recently we are no longer able to directly open links in the preview mode of the editor. We need to use shit+click or ctrl+click to open them. Of course this is a simple solution, but one of my clients is not happy with this behaviour. He just wants to click.

    You can see this behaviour in your demo here:

    Go to preview mode and try to click the link there. Nothing happens unless you ctrl+click it.
    Is this by design? It used to be possible to just click it. Is there a work around for this maybe?

    Using IE9, 2012.2.912.35 release.


  2. Rumen
    Rumen avatar
    14466 posts

    Posted 09 Oct 2012 Link to this post


    You can implement a custom content filter as shown in this forum thread:

    All the best,
    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.
  3. Yeroon
    Yeroon avatar
    87 posts
    Member since:
    Oct 2012

    Posted 16 Oct 2012 Link to this post

    Thanks for your reply. I implemented the provider but it still didn't work. When I view the source of the preview, it shows the link and target blank, but clicking still doesnt do anything.

    I found out what the problem is though. You have added an onclick='return false;' statement to the links. So if I extend the custom provider like below, things will work again:

    Added: link.removeAttribute("onclick");
    Added: link.setAttribute("onclick", "return false;");
    <script type="text/javascript">
            function OnClientLoad(editor) {
                editor.add_modeChange(function () {
                    //Convert all links to have target = "_blank" when user is in preview mode. Keep existing setting and restore it when user switches back
                    var mode = editor.get_mode();
                    var links = editor.get_document().getElementsByTagName("A");
                    for (var i = 0; i < links.length; i++) {
                        var link = links[i];
                        //Keep old setting, set target=blank
                        if (mode == Telerik.Web.UI.EditModes.Preview) {
                            link.setAttribute("original_target", link.getAttribute("target"));
                            link.setAttribute("target", "_blank");
                        else {
                            var target = link.getAttribute("original_target");
                            if (target) link.setAttribute("target", target);
                            link.setAttribute("onclick", "return false;");

Back to Top