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

Links in preview mode dont open anymore

2 Answers 41 Views
Editor
This is a migrated thread and some comments may be shown as answers.
Yeroon
Top achievements
Rank 2
Yeroon asked on 05 Oct 2012, 08:45 AM
Hello,

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:

http://demos.telerik.com/aspnet-ajax/editor/examples/customdialogs/defaultcs.aspx

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.

Thanks!

Yeroon

2 Answers, 1 is accepted

Sort by
0
Rumen
Telerik team
answered on 09 Oct 2012, 03:10 PM
Hi,

You can implement a custom content filter as shown in this forum thread:
http://www.telerik.com/community/forums/aspnet-ajax/editor/have-links-in-preview-mode-open-in-new-window.aspx

All the best,
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
Yeroon
Top achievements
Rank 2
answered on 16 Oct 2012, 09:46 AM
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");
                        link.removeAttribute("onclick");
                         
                    }
                    else {
                        var target = link.getAttribute("original_target");
                        if (target) link.setAttribute("target", target);
                        link.removeAttribute("original_target");
                        link.setAttribute("onclick", "return false;");
                    }
                }
            });
        }
    </script>


Tags
Editor
Asked by
Yeroon
Top achievements
Rank 2
Answers by
Rumen
Telerik team
Yeroon
Top achievements
Rank 2
Share this question
or