Skip to content

Instantly share code, notes, and snippets.

@anehkumar
Created August 25, 2020 13:06
Show Gist options
  • Save anehkumar/328f488f81dc584c1dee92d10e143312 to your computer and use it in GitHub Desktop.
Save anehkumar/328f488f81dc584c1dee92d10e143312 to your computer and use it in GitHub Desktop.
<script>
var isMobile = false;
if (navigator.userAgent !== undefined) {
var userAgent = navigator.userAgent.toLowerCase();
var iPhoneIndex = userAgent.indexOf("iphone");
var iPadIndex = userAgent.indexOf("ipad");
var isIPhone = (iPhoneIndex !== -1 && iPadIndex === -1) || (iPhoneIndex !== -1 && iPhoneIndex < iPadIndex);
var isAndroid = userAgent.indexOf("android") !== -1 && userAgent.indexOf("mobile") !== -1;
var isOtherMobile = userAgent.match(/^.*?(ipod|blackberry|mini|windows\\sce|palm|phone|mobile|smartphone|iemobile).*?$/) != null;
isMobile = isIPhone || isAndroid || isOtherMobile;
}
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment