2011-05-19 71 views

回答

3

爲此,您需要複製tinymce插入鏈接插件,重新命名,添加必要的代碼(「http」-Adding)並將其用作您自己的插件。

編輯:好的,這是(使用jQuery)的示例:在TinyMCE的insertLink.aspx文件:

// You might need to change the event and/or tha handling 
// but this should give you a guess at what needs to be done 
setup : function(ed) 
{ 
     ed.onClick.add(function(ed, evt) 
     { 
      $(ed.getBody()).find('a').each(function(index, element){ 
       if (!$(this).attr('href').search('http')){ 
        $(this).attr('href', 'http://' + $(this).attr('href')); 
       } 
      }); 
     }); 
}, 
+0

感謝Thariama。有沒有其他方法可以做到這一點? – Saim 2011-05-20 15:06:21

+0

您可以使用setup參數或自己的插件來實現偵聽指定事件的處理程序。這個處理程序可以搜索鏈接的內容,並檢查他們是否設置了「http」。 – Thariama 2011-05-23 08:24:28

+0

再次感謝,能否請您提供一些示例代碼來說明如何實現?我將不勝感激。 – Saim 2011-05-23 10:06:56

1

我已通過預填充有 '// HTTP' 字段值來實現這一點。

<ui:PropertyPanel runat="server" Text="Url"> 
    <input type="hidden" id="localUrl" name="localUrl" onchange="" /> 
    <input id="href" name="href" type="text" style="width: 220px;" value="http://" onchange="document.getElementById('localUrl').value = ''; 
selectByValue(this.form,'linklisthref',this.value);" /> 
</ui:PropertyPanel> 

值= 「HTTP://」

0
在link.js

,發現 「如果(!f.href.value)」

添加一個 「其他」 條款

else { 
     var href = f.href.value; 
     if (href.indexOf('http') == -1) { 
      href = 'http://' + href; 
      f.href.value = href; 
     } 
    } 

**請記住,如果你更新了你的tinymce組件,

3

我在4.x版本中遇到了這個問題。我發現link插件支持一個提示用戶添加協議的選項。但不幸的是,它沒有在文檔中提到,它只記錄在更新日誌中,所以我可以想象這是廣泛未知的。

$('textarea').tinymce({ 
    ... 
    link_assume_external_targets: true 
    ... 
}); 

enter image description here

+0

這有幫助。謝謝。 – 2016-09-28 20:33:36

+0

是否有跳過此警報並強制將http://添加到沒有http/https的所有鏈接的選項? – Arun 2016-10-24 14:54:38

+0

據我所知,當我研究這個時,沒有。事情可能已經改變了。 – EternalHour 2016-10-24 23:26:02