| 176 | | * Focus the target of skip link after pressing Enter. |
| 177 | | * |
| 178 | | * @since 5.3.1 |
| 179 | | * |
| 180 | | * @param {Event} event The keydown event. |
| 181 | | */ |
| 182 | | function focusTargetAfterEnter( event ) { |
| 183 | | var id, userAgent; |
| 184 | | |
| 185 | | if ( event.which !== 13 ) { |
| 186 | | return; |
| 187 | | } |
| 188 | | |
| 189 | | id = event.target.getAttribute( 'href' ); |
| 190 | | userAgent = navigator.userAgent.toLowerCase(); |
| 191 | | |
| 192 | | if ( userAgent.indexOf( 'applewebkit' ) > -1 && id && id.charAt( 0 ) === '#' ) { |
| 193 | | setTimeout( function() { |
| 194 | | var target = document.getElementById( id.replace( '#', '' ) ); |
| 195 | | |
| 196 | | if ( target ) { |
| 197 | | target.setAttribute( 'tabIndex', '0' ); |
| 198 | | target.focus(); |
| 199 | | } |
| 200 | | }, 100 ); |
| 201 | | } |
| 202 | | } |
| 203 | | |
| 204 | | /** |