<html>
<head>
<title>浏览器篇(一)</title>
<script language="javaScript">
//获得浏览器的名字
function getAppName() {
info = navigator.appName;
document.write("浏览器的名字是:" + info);
}
//判断作用的浏览器
function confirmAppName() {
info = navigator.appName.toUpperCase();
if(info == "MICROSOFT INTERNET EXPLORER") {
document.write("你正在使用的是IE浏览器");
} else if(info == "NETSCAPE") {
document.write("你正在作用的是NetScape");
} else {
document.write("你正在使用其它浏览器");
}
}
//获得浏览器的版本号
function getAppVersion() {
ver = navigator.appVersion.toUpperCase();
info = navigator.appName.toUpperCase();
if(info == "MICROSOFT INTERNET EXPLORER") {
//ver 的值是:(compatible; MSIE 6.0; Windows NT 5.1; SV1)
index = ver.indexOf("MSIE",0) + 4;
ver = ver.substring(index, index+4);
document.write("你使用的浏览器是:Internet Explorer" + ver);
} else if(info == "NETSCAPE") {
ver = ver.substring(ver, 4);
document.write("你使用的浏览器是:NetScape" + ver);
}
}
</script>
</head>
<body>
<script language="javascript">
getAppName();
document.write("<br>");
confirmAppName();
document.write("<br>");
getAppVersion();
</script>
</body>
</html>
浙公网安备 33010602011771号