CoreFiles by mySites.guru
skip-link-focus-fix.js33 lines, 935 bytes, from wordpress-4.4-beta2.zip
Raw History Compare with 4.4-beta1
md5
8f47854db754a115c94b22cebae0c66b
sha1
3d24f728e5e3828e3a5a6fb7fea80a2c19eda3d8
sha256
70e9c6fa45892c48adb80abedd936c43935d08c279b20fc0c30aca6056d6bc84
/**
 * 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 isWebkit = navigator.userAgent.toLowerCase().indexOf( 'webkit' ) > -1,
		isOpera  = navigator.userAgent.toLowerCase().indexOf( 'opera' )  > -1,
		isIE     = navigator.userAgent.toLowerCase().indexOf( 'msie' )   > -1;

	if ( ( isWebkit || isOpera || isIE ) && document.getElementById && window.addEventListener ) {
		window.addEventListener( 'hashchange', function() {
			var id = location.hash.substring( 1 ),
				element;

			if ( ! ( /^[A-z0-9_-]+$/.test( id ) ) ) {
				return;
			}

			element = document.getElementById( id );

			if ( element ) {
				if ( ! ( /^(?:a|select|input|button|textarea)$/i.test( element.tagName ) ) ) {
					element.tabIndex = -1;
				}

				element.focus();
			}
		}, false );
	}
} )();

The same content is in 4 releases, WordPress 4.4-beta1 to 4.4-beta4. See them all, or every version of this file.