8

I have below configuration for tinymce. I want to open the result of hyperlink click in separate tab or window. I used theme_advanced_link_targets : "_blank" as shown below but did not help. Is there any other cofig paramter for this?

  var tinyMCESettings = {
    theme : "advanced",
    plugins : "preview",
    readonly : readOnly,
    theme_advanced_buttons1 : "forecolor,backcolor,|,justifyleft,justifycenter,justifyright,justifyfull",
    width : width,
    theme_advanced_toolbar_location : "top",
    theme_advanced_toolbar_align : "left",
    theme_advanced_statusbar_location : "false",
    theme_advanced_link_targets : "_blank",
    forced_root_block : false,
    relative_urls : false,
    remove_script_host : false
  }

2 Answers 2

17

For TinyMCE 4.0.23 you can use the (undocumented) option:

default_link_target:"_blank"

as is:

tinymce.init({
    selector: "textarea.rta",
    auto_focus: rta_auto_focus,
    forced_root_block : false,
    statusbar:  false,
    menubar:    false,
    content_css : "content.min.css",
    plugins: [
        "autolink lists link autoresize",
        "searchreplace code",
        "paste"
    ],
    default_link_target:"_blank",
    toolbar: "undo redo | bold italic underline | alignleft aligncenter alignright alignjustify | bullist numlist outdent indent | link"
});
5
  • This worked great after upgrading to TinyMCE 4.1.7. However, I'm wondering why it's undocumented and if it's a feature that will remain in future releases. Do you by chance have any information about that? Jan 7, 2015 at 15:50
  • A question though i have is that, isnt the click event of a link inside TinyMCE disabled? Jan 6, 2016 at 6:18
  • @BhumiSinghal It is disabled but this allows the the html that is saved to have target="_blank" to be included with the markup when you export/save the data from the editor. May 15, 2017 at 16:37
  • 1
    There the documentation link with anchor: tinymce.com/docs/plugins/link/#default_link_target
    – wittich
    Aug 29, 2017 at 22:09
  • 1
    For newer versions is link_default_target:"_blank"
    – XAronX
    Aug 17, 2023 at 15:02
9

Got it resolved with parameter

    extended_valid_elements : "a[href|target=_blank]"
1
  • but you cant turn it off, after you try to edit in the popup-settings and remove "open in new window" you cant turn it off
    – John Smith
    Feb 18, 2021 at 14:19

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.