forked from learning-zone/javascript-basics
-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathbrowser-type.html
More file actions
37 lines (34 loc) · 1.31 KB
/
browser-type.html
File metadata and controls
37 lines (34 loc) · 1.31 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
<!DOCTYPE html>
<html>
<head>
<title>Detect Browser Type</title>
</head>
<script>
/* *
* -------------------------------------------------------------------------
* Engine Embedded in
* -------------------------------------------------------------------------
* WebKit Safari browser, plus all browsers hosted on the iOS App Store
* Blink Google Chrome and all other Chromium-based browsers like Opera and Microsoft Edge
* Gecko Firefox browser and Thunderbird email client, plus forks like SeaMonkey and Waterfox
* EdgeHTML formerly in the Microsoft Edge browser
* Trident Internet Explorer browser and Microsoft Outlook email client
*
* */
var browser,
agt = navigator.userAgent.toLowerCase();
if (agt.indexOf('chrome') > -1) {
browser = 'Google Chrome';
} else if (agt.indexOf('safari') > -1) {
browser = 'Apple Safari';
} else if (agt.indexOf('opera') > -1) {
browser = 'Opera';
} else if (agt.indexOf('firefox') > -1) {
browser = 'Mozilla Firefox';
} else if (agt.indexOf('mise') > -1 || agt.indexOf('trident') > -1) {
browser = 'Microsoft Internet Explorer';
}
alert('You are using: ' + browser + " \n\nNavigator: " +agt);
</script>
<body>Checking browser type...</body>
</html>