简体   繁体   English

在RTF编辑器中覆盖IE电子邮件自动格式化

[英]Override IE email auto-formatting in rich-text editor

Our site makes use of FreeTextBox , a web-based, rich-text editor. 我们的网站使用FreeTextBox ,这是一个基于Web的富文本编辑器。 In IE, but in not Firefox, if a user types in something like: 在IE中,但在Firefox中,如果用户键入以下内容:

someone@blah 某人@blah

IE automatically creates a mailto hyperlink. IE自动创建一个mailto超链接。 I have tested this with other text editors out there and the story is the same with all of them. 我已经与其他文本编辑器进行了测试,所有的故事都是一样的。

Can I override this browser behavior somehow from within my application? 我可以从我的应用程序中以某种方式覆盖此浏览器行为吗?

This has to do with the MSHTML editor, which (I'm guessing all) Windows browsers use to instantiate rich text editors. 这与MSHTML编辑器有关(我猜是所有),Windows浏览器用来实例化RTF编辑器。 There's a setting called IDM_AUTOURLDETECT_MODE that lets you decide if the autolinking will take place, and the default is true (other browsers apparently set it to false on instantiation, hence no autolinking in Firefox.) 有一个名为IDM_AUTOURLDETECT_MODE的设置,可让您决定是否进行自动链接,默认设置为true(其他浏览器显然在实例化时将其设置为false,因此在Firefox中没有自动链接。)

Unfortunately, until recently Microsoft didn't have a mapping from the command ID to a command identifier string, so the function wasn't accessible via Javascript prior to IE9. 不幸的是,直到最近,Microsoft才没有从命令ID到命令标识符字符串的映射,因此该功能在IE9之前无法通过Javascript访问。

I just tried it out in IE9 and can confirm that, for that version and presumably all future ones, you can override the feature by calling 我刚刚在IE9中进行了尝试,可以确认对于该版本以及将来的所有版本,您可以通过调用覆盖该功能

document.execCommand("AutoUrlDetect", false, false);

Note that it's IE9+ only, so you're still stuck for previous versions, and that you'll want to wait until the DOM is loaded before you call it and have some error handling around it, etc, etc. 请注意,它仅适用于IE9 +,因此您仍然对以前的版本感到困惑,并且您将要等到DOM加载后再调用它,并对它进行一些错误处理,等等,等等。

There's a good summary of the original issue here , and a discussion of the fix in the minor change list here . 还有原来的问题的一个很好的总结在这里 ,和修复的微小变化列表的讨论在这里

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM