Site Navigation

Showing posts with label link. Show all posts
Showing posts with label link. Show all posts

Thursday, November 13, 2008

bug 505 - you can't programatically focus a link in IE unless another link has the focus

Issue: #505
Affects: IE6, IE7, IE8

Here's the scenario: You want to put the current focus on a hyperlink on the page, complete with that dotted border that indicates to the user, that the link has the focus.

Easy enough, right?

Example:

<script type="text/javascript">
var firstLink = document.getElementsByTagName('a')[0];
firstLink.focus();
</script>


Well, try it out. In fact, just drop it in the location bar of any other browser as a bookmarklet to verify that it works.


javascript:document.getElementsByTagName('a')[0].focus();


Try the same thing in IE, and you'll notice that the dotted border doesn't show up! Press Tab, and you'll move focus to the next filed, press Shift Tab, and you'll move back, complete with the dotted border. The link does have the focus though... press Enter and you will activate the link.

To see how it should work, press Tab to move between the links on the page. Once you are on a link, complete with the visible dotted border focus, now call .focus() on any other link. Thus it only works in IE, if another link already has the focus, and it was achieved manually.



Known Workarounds: None.



Related Issues: None.


Bug/Site Feedback |
Submit a bug

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