Created
October 5, 2022 21:10
-
-
Save ZhouYang1993/b64f907958b00121a3b60a86396a4f78 to your computer and use it in GitHub Desktop.
Detect Mobile Devices in JavaScript
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 onClick() { | |
if ((/Android/i.test(navigator.userAgent))) { | |
// go to Google Play Store | |
} | |
if (/iPad|iPhone|iPod/i.test(navigator.userAgent)) { | |
// go to App Store | |
} | |
else { | |
// go to another website | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment