TinyMCE:如果不在那里,如何将“http://”添加到URL [英] TinyMCE: How to prepend 'http://' to URL if it's not there
本文介绍了TinyMCE:如果不在那里,如何将“http://”添加到URL的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如果在TinyMCE中添加带有插入链接的URL时,有没有办法将http://添加到URL中?
Is there way to prepend 'http://' to URL if it's not there while adding URL with Insert Link in TinyMCE?
推荐答案
为此您需要复制tinymce Insert Link插件,重命名,添加必要的代码(http - 添加)并将其用作您自己的插件。
For that you would need to copy the tinymce Insert Link plugin, rename it, add the necessary code to it (the "http"-Adding) and use it as your own plugin.
编辑:好的,这是一个例子(使用jQuery):
Ok, here is an example (using jQuery):
// 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'));
}
});
});
},
这篇关于TinyMCE:如果不在那里,如何将“http://”添加到URL的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文