<html>
<head>
<title>TAG index Web</title>
</head>
<body>
<script type="text/javascript">
<!--
document.write('<p>浏览器判別:<br>');
// 包含「Opera」文字列
if(navigator.userAgent.indexOf("Opera") != -1) {
document.write('您的浏览器时Opera吧?');
}
// 包含「MSIE」文字列
else if(navigator.userAgent.indexOf("MSIE") != -1) {
document.write('您的浏览器时Internet Explorer吧?');
}
// 包含「Firefox」文字列
else if(navigator.userAgent.indexOf("Firefox") != -1) {
document.write('您的浏览器时Firefox吧?');
}
// 包含「Netscape」文字列
else if(navigator.userAgent.indexOf("Netscape") != -1) {
document.write('您的浏览器时Netscape吧?');
}
// 包含「Safari」文字列
else if(navigator.userAgent.indexOf("Safari") != -1) {
document.write('您的浏览器时Safari 吧?');
}
else{
document.write('无法识别的浏览器。');
}
document.write('</p>');
// -->
</script>
</body>
</html>
本文介绍了一种使用JavaScript来检测用户浏览器类型的方法。通过检查navigator.userAgent属性中的特定字符串,可以判断出用户正在使用的浏览器种类,如Opera、Internet Explorer、Firefox、Netscape或Safari等。

被折叠的 条评论
为什么被折叠?



