Skip to content

Instantly share code, notes, and snippets.

@bradbaris
Created May 11, 2016 07:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bradbaris/c1351bd8dce512574c2ba4561aaf7120 to your computer and use it in GitHub Desktop.
Save bradbaris/c1351bd8dce512574c2ba4561aaf7120 to your computer and use it in GitHub Desktop.
/**
* @fileoverview Utility functions related to the user agent.
*/
function isIOS() {
return /iPhone|iPad|iPod/i.test(navigator.userAgent);
}
function isAndroid() {
return /Android/i.test(navigator.userAgent);
}
function isIE() {
return /MSIE\/\d+/.test(navigator.userAgent);
}
function isIEorEdge() {
return /Edge\/\d+/.test(navigator.userAgent) ||
/MSIE\/\d+/.test(navigator.userAgent) ||
/Trident\/\d+/.test(navigator.userAgent);
}
module.exports = {
isAndroid: isAndroid,
isIOS: isIOS,
isIE: isIE,
isIEorEdge: isIEorEdge
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment