I know this is an old question, but I finally stumbled upon it today after searching for a watch. I still have not found a non-js solution for this, and although the problem is marked as fixed in Chrome, it still exhibits the same behavior. Due to the lack of anything else, I used jQuery. Instead of an inline script, I used an unobtrusive event listener.
HTML:
<div id="skiptocontent"> <a href="#mainContent" id="skipper">Skip to Main Content</a> </div> <div id="mainContent"></div>
jQuery:
$(document).ready(function () { $("#skipper").click(function () { $('#mainContent').attr('tabIndex', -1).focus(); }); });
I also hide the link if it does not receive focus from the keyboard. Thus, only users of the keyboard and screen readers will know that there is a connection. Using CSS3, you can make sure that it becomes short-lived if the user quickly closes it.
CSS:
#skiptocontent a { position: absolute; top:-40px; left:0px; background:transparent; -webkit-transition: top 1s ease-out, background 1s linear; transition: top 1s ease-out, background 1s linear; z-index: 100 } #skiptocontent a:focus { position:absolute; left:0px; top:0px; background:#F1B82D; -webkit-transition: top .1s ease-in, background .5s linear; transition: top .1s ease-in, background .5s linear }
For a demonstration, you can view the fiddle . If anyone has a way to use javascript, I'd love to hear it. I don't think the solution is really affordable if it requires js.
Matthew johnson
source share