We are using the Kendo UI Editor control. How can I force it to only insert links that will open into a new window (i.e. target=”_blank”)?
This needs to be done in javascript, not Razor. I have tried getting it on the execute and select events, but neither have worked so far.
There are two ways to do this:
Automatically check the “Open link in new window” checkbox in the “Insert link” dialog. Here is a sample implementation: http://jsbin.com/ekibud/1/edit. The idea is to subscribe to the
executeevent of the editor and if the command is “createlink” check the checkbox. Here is the required code:Find all links in the editor content and set their target attribute. This can be done via JavaScript and a regular expression replace: