Comments on: Fixing “:focus” in Internet Explorer https://j11y.io/snippets/fixing-focus-in-internet-explorer/ Sun, 22 Mar 2015 15:39:22 +0000 hourly 1 https://wordpress.org/?v=5.0.13 By: Live-Dimension https://j11y.io/snippets/fixing-focus-in-internet-explorer/#comment-861 Thu, 16 Apr 2009 23:01:51 +0000 https://j11y.io/?p=760#comment-861 I believe I know of an almost better solution, especially if your not using JQuery.

http://www.xs4all.nl/~peterned/csshover.html
What this is is an internet explorer “behaviour”. Basically, you just shove this in your css.

body { behavior: url(“csshover3.htc”); }

Note that the file is relative to the HTML file calling, NOT the css. Of course, this is non-standards. Conditional comments pretty much fixes that – so it’s usually easier to just use a tag and put the behaviour in there.

Anyway, AFAIK it fixes :hover, :active, :focus for ALL elements from IE 6 and later (though :focus isn’t in IE6 from what I’ve just read).

]]>
By: anthony https://j11y.io/snippets/fixing-focus-in-internet-explorer/#comment-860 Thu, 16 Apr 2009 19:52:57 +0000 https://j11y.io/?p=760#comment-860 That’s pretty good. I would put something in the focusIsSupported function to find the currently focused element, then refocus it before returning. That way whatever element is focused on page load is still the focused element when the function returns.

Something like
var currentFocus = document.activeElement || null;
// code to check focus
if(currentFocus) currentFocus.focus();

return supported;

document.activeElement doesn’t work on all browsers, but since IE it works in IE and IE is the problem, it should be okay.

]]>
By: Schalk Neethling https://j11y.io/snippets/fixing-focus-in-internet-explorer/#comment-859 Thu, 16 Apr 2009 17:30:14 +0000 https://j11y.io/?p=760#comment-859 Nice stuff James! Will definitely try this out.

]]>