Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to open hyperlink in new window under tinymce text editor?

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
  }
like image 365
emilly Avatar asked Sep 19 '13 05:09

emilly


People also ask

How do you hyperlink in TinyMCE?

Add hyperlinks to content.The toolbar button and menu item called link are included in TinyMCE's default configuration. The link menu item can be found in the Insert menu. The link plugin also includes a context menu and context toolbar.

How do you get text from TinyMCE editor?

The TinyMCE getContent and setContent methods You can do this using the getContent() API method. Let's say you have initialized the editor on a textarea with id=”myTextarea”. This will return the content in the editor marked up as HTML.


2 Answers

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"
});
like image 70
anagnostatos Avatar answered Oct 01 '22 19:10

anagnostatos


Got it resolved with parameter

    extended_valid_elements : "a[href|target=_blank]"
like image 34
emilly Avatar answered Oct 01 '22 20:10

emilly