Disable automatic detection of hyperlinks with contentEditable (IE 5.5+)

G

gboissiere

Hello 'contentEditable' gurus,

The example code below uses contentEditable to let the user edit the
<div> element directly in their browser. Works also using designMode
for the document.

However, if the user edits the <div> by typing:
"(e-mail address removed) is listed on the www.yahoo.com webpage"
IE 5.5+ automatically detects the email address and the URL and creates
those 2 hyperlinks automatically.

Is there a way to prevent IE from creating those links automatically?
The same code works fine in Mozilla 1.0+.
Thanks,

Guillaume


<HTML>
<HEAD>
</HEAD>
<BODY>
<DIV ID="oDiv">Type your text here...</DIV>
<SCRIPT>
<!--
oDiv.contentEditable = true;
// -->
</SCRIPT>
</BODY>
</HTML>
 
C

Csaba Gabor

Hello 'contentEditable' gurus,

The example code below uses contentEditable to let the user edit the ....
However, if the user edits the <div> by typing:
"(e-mail address removed) is listed on the www.yahoo.com webpage"
IE 5.5+ automatically detects the email address and the URL and creates
those 2 hyperlinks automatically.

What a pain in the neck! Just some ideas for you... in case you
implement a solution, please do post it.

If you prefix the email or the web address with a double quote, IE
won't do the nasty. This, of course, is not an acceptable solution.

One possibility is to wait until the div loses the focus, and then do
something like mydiv.innerHTML = protect(mydiv.innerText). Still, the
user would be somewhat confused about what is going on. So, to ratchet
this up, you could do the same type of thing each time the div content
changes (however IE is buggy on this change detection, especially if
the entire element is erased. Example: type (e-mail address removed), then HOME
(note link), then SHIFT+END, then x, then y, then z. HELLO, IE, anyone
at home?!? Note that xyz is shown as a link even though there is no
cause. Now hit the BACKSPACE. Ah, now IE has woken up again). Or a
variation on this theme would be to replace '@', '.', and ':' with
their appropriate HTML entity as they are entered.

Good luck,
Csaba Gabor from Vienna
 
G

gboissiere

Spoke with Microsoft about this and apparently there is simply no way
to disable this.

It is hardcoded by IE mshtml.dll with all the following protocols:
www, http://, https://, ftp://, gopher://, mailto:, new:, stelnet:, wasis:, file://, nntp://, newsrc:, ldap://, ldaps://,
outlook:, mic:// and url:

The only workaround would be to use Javascript to detect and remove the
hyperlinks AFTER they have been created on each key press or click
event...

Guillaume
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Staff online

Members online

Forum statistics

Threads
473,764
Messages
2,569,566
Members
45,041
Latest member
RomeoFarnh

Latest Threads

Top