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

蓝咒 提交于 2020-01-13 11:22:11

问题


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
  }

回答1:


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"
});



回答2:


Got it resolved with parameter

    extended_valid_elements : "a[href|target=_blank]"


来源:https://stackoverflow.com/questions/18886712/how-to-open-hyperlink-in-new-window-under-tinymce-text-editor

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!