diff --git a/js/skip-link-focus-fix.js b/js/skip-link-focus-fix.js index e067cd51..044d0553 100644 --- a/js/skip-link-focus-fix.js +++ b/js/skip-link-focus-fix.js @@ -3,9 +3,8 @@ is_opera = navigator.userAgent.toLowerCase().indexOf( 'opera' ) > -1, is_ie = navigator.userAgent.toLowerCase().indexOf( 'msie' ) > -1; - if ( ( is_webkit || is_opera || is_ie ) && 'undefined' !== typeof( document.getElementById ) ) { - var eventMethod = ( window.addEventListener ) ? 'addEventListener' : 'attachEvent'; - window[ eventMethod ]( 'hashchange', function() { + if ( ( is_webkit || is_opera || is_ie ) && document.getElementById && window.addEventListener ) { + window.addEventListener( 'hashchange', function() { var element = document.getElementById( location.hash.substring( 1 ) ); if ( element ) {