Skip to content

Commit e3d4d85

Browse files
authored
Create Browsers Detection in JS
1 parent 846c268 commit e3d4d85

File tree

1 file changed

+39
-0
lines changed

1 file changed

+39
-0
lines changed

Browsers Detection in JS

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
There is a simple JavaScript which can be used to find out the name of a browser and then accordingly an HTML page can be served to the user.
2+
and this is really help you ..
3+
<html>
4+
<head>
5+
<title>Browser Detection Example</title>
6+
</head>
7+
8+
<body>
9+
<script type = "text/javascript">
10+
<!--
11+
var userAgent = navigator.userAgent;
12+
var opera = (userAgent.indexOf('Opera') != -1);
13+
var ie = (userAgent.indexOf('MSIE') != -1);
14+
var gecko = (userAgent.indexOf('Gecko') != -1);
15+
var netscape = (userAgent.indexOf('Mozilla') != -1);
16+
var version = navigator.appVersion;
17+
18+
if (opera) {
19+
document.write("Opera based browser");
20+
// Keep your opera specific URL here.
21+
} else if (gecko) {
22+
document.write("Mozilla based browser");
23+
// Keep your gecko specific URL here.
24+
} else if (ie) {
25+
document.write("IE based browser");
26+
// Keep your IE specific URL here.
27+
} else if (netscape) {
28+
document.write("Netscape based browser");
29+
// Keep your Netscape specific URL here.
30+
} else {
31+
document.write("Unknown browser");
32+
}
33+
34+
// You can include version to along with any above condition.
35+
document.write("<br /> Browser version info : " + version );
36+
//-->
37+
</script>
38+
</body>
39+
</html>

0 commit comments

Comments
 (0)