Javascript 判断客户端浏览器类型代码
<script type="text/javascript">
/*详细方法1*/
function CheckBrowser()
{
var app=navigator.appName;
var verStr=navigator.appVersion;
//火狐浏览器
if (app.indexOf('Netscape') != -1)
{
alert("你使用的是Netscape浏览器或火狐浏览器。");
}
else if (app.indexOf('Microsoft') != -1)
{
if (verStr.indexOf("MSIE 3.0")!=-1 || verStr.indexOf("MSIE 4.0") != -1 || verStr.indexOf("MSIE 5.0") != -1 || verStr.indexOf("MSIE 5.1") != -1)
{
alert("您使用的是低版本(IE6.0以下)的浏览器.");
}
else
{
alert("您使用的是IE6.0以上的浏览器.");
}
}
}
/*简洁方法2*/
function CheckBrowser1()
{
if (window.navigator.userAgent.indexOf("MSIE")>=1)
//如果浏览器为IE
{
alert("IE浏览器");
}
else //如果浏览器为Firefox
{
if (window.navigator.userAgent.indexOf("Firefox")>=1)
{
alert("Fixfox浏览器");
}
}
}
//调用
CheckBrowser();
CheckBrowser1();
</script>
document.write("Screen resolution: ")
document.write(screen.width + "*" + screen.height)
document.write("<br />")
document.write("Available view area: ")
document.write(screen.availWidth + "*" + screen.availHeight)
document.write("<br />")
document.write("Color depth: ")
document.write(screen.colorDepth)
document.write("<br />")
document.write("Buffer depth: ")
document.write(screen.bufferDepth)
document.write("<br />")
document.write("DeviceXDPI: ")
document.write(screen.deviceXDPI)
document.write("<br />")
document.write("DeviceYDPI: ")
document.write(screen.deviceYDPI)
document.write("<br />")
document.write("LogicalXDPI: ")
document.write(screen.logicalXDPI)
document.write("<br />")
document.write("LogicalYDPI: ")
document.write(screen.logicalYDPI)
document.write("<br />")
document.write("FontSmoothingEnabled: ")
document.write(screen.fontSmoothingEnabled)
document.write("<br />")
document.write("PixelDepth: ")
document.write(screen.pixelDepth)
document.write("<br />")
document.write("UpdateInterval: ")
document.write(screen.updateInterval)
document.write("<br />")