mirror of
https://github.com/WordPress/WordPress.git
synced 2024-11-05 02:10:45 +01:00
ca92ca385e
Built from https://develop.svn.wordpress.org/trunk@29897 git-svn-id: http://core.svn.wordpress.org/trunk@29652 1a063a9b-81f0-0310-95a4-ce76da25c4cd
27 lines
727 B
JavaScript
27 lines
727 B
JavaScript
/**
|
|
* Makes "skip to content" link work correctly in IE9, Chrome, and Opera
|
|
* for better accessibility.
|
|
*
|
|
* @link http://www.nczonline.net/blog/2013/01/15/fixing-skip-to-content-links/
|
|
*/
|
|
|
|
( function() {
|
|
var ua = navigator.userAgent.toLowerCase();
|
|
|
|
if ( ( ua.indexOf( 'webkit' ) > -1 || ua.indexOf( 'opera' ) > -1 || ua.indexOf( 'msie' ) > -1 ) &&
|
|
document.getElementById && window.addEventListener ) {
|
|
|
|
window.addEventListener( 'hashchange', function() {
|
|
var element = document.getElementById( location.hash.substring( 1 ) );
|
|
|
|
if ( element ) {
|
|
if ( ! /^(?:a|select|input|button|textarea)$/i.test( element.nodeName ) ) {
|
|
element.tabIndex = -1;
|
|
}
|
|
|
|
element.focus();
|
|
}
|
|
}, false );
|
|
}
|
|
} )();
|