Created
October 19, 2017 16:21
-
-
Save jpswade/03b527d7921541b96d62b62bdcf121b8 to your computer and use it in GitHub Desktop.
UserAgent detection
This file contains 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
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> | |
<html> | |
<head> | |
<title>Your UserAgent is...</title> | |
<meta http-equiv="Content-Type" content="text/html;charset=utf-8"> | |
<script type="text/javascript"> | |
var userAgent = navigator.userAgent.toLowerCase(); | |
var browserid = userAgent.match(/(firefox|chrome|safari|opera|msie)/)[1]; | |
var browserversion = (userAgent.match(new RegExp('.+(?:version)[\/: ]([\\d.]+)')) || userAgent.match(new RegExp('.+(?:' + browserid + ')[\/: ]([\\d.]+)')) || [0, '0'])[1]; | |
</script> | |
</head> | |
<body> | |
<p><script type="text/javascript"> | |
document.write(userAgent); | |
</script></p> | |
<p>That was detected as: | |
<script type="text/javascript"> | |
document.write(browserid); | |
</script></p> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment