I have set a link to some text using tinymce.execCommand("CreateLink", False, theLink)
. The problem is that I want to set "Target=_blank"
.
How do I set a Target
attribute after the above?
Thanks.
Are you trying to set the target attribute to _blank on all user-provided links in TinyMCE? If so, set this property in your tinymce.init configuration:
extended_valid_elements: 'a[href|target=_blank]'
This works for me on TinyMCE 4.0.2.
With this configuration, all links in the editor will have target set to _blank when the editor saves. (Additionally, all attributes other than href and target will be removed since I excluded them in the configuration; add whatever valid attributes/constraints that you wish to allow.)
see: http://www.tinymce.com/wiki.php/configuration:extended_valid_elements
If these are user-provided links, then you may also want to set rel=nofollow for all links they provide.
Making 'New page' an only option did work for me (see: http://www.tinymce.com/wiki.php/Configuration:target_list) in version 4.1.0
target_list: [ {title: 'New page', value: '_blank', selected: true} ]
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With