ソース コード

<html>
<head>
<script language="JavaScript">
    function NNCheck(version) {
        if((navigator.appName.indexOf('Netscape') >= 0)
        && (version <= parseInt(navigator.appVersion.substring(0, 3)))) {
            return true;
        } else {
            return false;
        }
    }

    function IECheck(version) {
        if((navigator.appName.indexOf('Microsoft Internet Explorer') >= 0)
        && (version <= parseInt(navigator.appVersion.substring(22, 25)))) {
            return true;
        } else {
            return false;
        }
    }

    function MinorVerCheck() {
        if(IECheck(4)) {
            str = typeof(navigator.appMinorVersion);
            if(str.indexOf("undefined") < 0) {
                return true;
            }
        }
        return false;
    }

    function PlatformCheck() {
        if(NNCheck(4) || IECheck(4)) {
            str = typeof(navigator.platform);
            if(str.indexOf("undefined") < 0) {
                return true;
            }
        }
        return false;
    }

    function CPUClassCheck() {
        if(IECheck(4)) {
            str = typeof(navigator.cpuClass);
            if(str.indexOf("undefined") < 0) {
                return true;
            }
        }
        return false;
    }

    function ScrSizeCheck() {
        if(NNCheck(4) || IECheck(4)) {
            str = typeof(screen.height);
            if(str.indexOf("undefined") < 0) {
                str = typeof(screen.width);
                if(str.indexOf("undefined") < 0) {
                    return true;
                }
            }
        }
        return false;
    }

    function ColorBitCheck() {
        if(NNCheck(4)) {
            str = typeof(screen.pixelDepth);
            if(str.indexOf("undefined") < 0) {
                return true;
            }
        } else if(IECheck(4)) {
            str = typeof(screen.colorDepth);
            if(str.indexOf("undefined") < 0) {
                return true;
            }
        }
        return false;
    }
</script>
</head>

<body>
<script language="JavaScript">
    doc = "<p>あなたが使用しているブラウザは ";
    if(NNCheck(2)) {
        doc += "<em>Netscape Navigator<\/em> です。";
    } else if(IECheck(3)) {
        doc += "<em>Microsoft Internet Explorer<\/em> です。";
    } else {
        doc += "定義されていません。";
    }
    doc += "<\/p>";
    document.write(doc);

    doc = "<p>あなたが使用しているブラウザのバージョンは ";
    str = typeof(navigator.appVersion);
    if(str.indexOf("undefined") < 0) {
        doc += "<em>" + navigator.appVersion + "<\/em> です。";
    } else {
        doc += "定義されていません。";
    }
    doc += "<\/p>";
    document.write(doc);

    doc = "<p>あなたが使用しているブラウザのマイナー バージョンは ";
    if(MinorVerCheck()) {
        doc += "<em>" + navigator.appMinorVersion + "<\/em> です。";
    } else {
        doc += "定義されていません。";
    }
    doc += "<\/p>";
    document.write(doc);

    doc = "<p>あなたが使用しているプラットフォームは ";
    if(PlatformCheck()) {
        doc += "<em>" + navigator.platform + "<\/em> です。";
    } else {
        doc += "定義されていません。";
    }
    doc += "<\/p>";
    document.write(doc);

    doc = "<p>あなたが使用しているCPUクラスは ";
    if(CPUClassCheck()) {
        doc += "<em>"+navigator.cpuClass+"<\/em> です。";
    } else {
        doc += "定義されていません。";
    }
    doc += "<\/p>";
    document.write(doc);

    doc = "<p>あなたが使用している画面のサイズは ";
    if(ScrSizeCheck()) {
        doc += "<em>" + screen.width + "×" + screen.height + "<\/em> です。";
    } else {
        doc += "定義されていません。";
    }
    doc += "<\/p>";
    document.write(doc);

    doc = "<p>あなたが使用している画面の表\示ビット数は ";
    if(ColorBitCheck()) {
        doc += "<em>" + (NNCheck(4) ? screen.pixelDepth : screen.colorDepth) + "ビット<\/em>、表\示色数は ";
        str = "";
        num1 = NNCheck(4) ? screen.pixelDepth : screen.colorDepth;
        num2 = Math.pow(2, (num1 > 24 ? 24 : num1));
        if(num2 >= 10000000) {
            str = Math.floor(num2 / 10000000).toString() + ",";
        }
        if(num2 >= 10000) {
            str += Math.floor((num2 % 10000000) / 10000).toString() + "万";
        }
        if(num2 >= 1000) {
            str += Math.floor((num2 % 10000) / 1000).toString() + ",";
        }
        str += (num2 % 1000).toString();
        doc += "<em>" + str + "色<\/em> です。";
    } else {
        doc += "定義されていません。";
    }
    doc += "<\/p>";
    document.write(doc);
</script>
</body>
</html>