Created
December 23, 2011 16:40
-
-
Save charleshimmer/1514696 to your computer and use it in GitHub Desktop.
Testing autofocus
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function featureTest(element, attribute); | |
var el = document.createElement('input'); | |
if(attribute in el){ | |
return true; | |
else{ | |
return false; | |
} | |
} | |
// to test if an browser supports the new HTML 5 autofocus attribute you would do this | |
if( ! featureText('input', 'autofocus')){ | |
// place JavaScript fallback (i.e. polyfill here) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment