Site Navigation

Tuesday, July 8, 2008

bug 140 - changing mailto: links error in IE

Issue: #140
Affects: IE6, IE7, IE8 Beta 1, IE8 Beta 2, IE8 PR1, IE8 RC1

If you've ever wanted to set the href attribute of a link (a element) to a URL that uses the mailto: protocol, beware...

In IE, if you set this href attribute to "mailto:name@example.com" or any other string that contains the "mailto:" protocol and the @ symbol, IE will overwrite the content of the a element.

Example:

<a id="contactLink" href="http://www.example.com/about.html">
Send us your thoughts!
</a>
<script type="text/javascript">
var cL = document.getElementById('contactLink');

//this fails in IE
cL.href = 'mailto:info@example.com?subject=My%20Thoughts';

//this also fails in IE
cL.setAttribute('href','mailto:info@example.com?subject=My%20Thoughts');
</script>


Using the code above, would transform the link from this:
Send us your thoughts!
to this:
mailto:info@example.com?subject=My%20Thoughts



Known Workarounds: None.



Related Issues: None.


Bug/Site Feedback |
Submit a bug