为什么javascript输出没有?

时间:2009-12-12 07:36:29

标签: javascript html xhtml

为什么javascript输出没有?它应该输出一些HTML代码。

<html>
<head>
<script type="text/javascript"><!--`

var keyStr = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";

function d64(input) {
    var output = new StringMaker();
    var chr1, chr2, chr3;
    var enc1, enc2, enc3, enc4;
    var i = 0;

    // remove all characters that are not A-Z, a-z, 0-9, +, /, or =
    input = input.replace(/[^A-Za-z0-9\+\/\=]/g, "");

    while (i < input.length) {
        enc1 = keyStr.indexOf(input.charAt(i++));
        enc2 = keyStr.indexOf(input.charAt(i++));
        enc3 = keyStr.indexOf(input.charAt(i++));
        enc4 = keyStr.indexOf(input.charAt(i++));

        chr1 = (enc1 << 2) | (enc2 >> 4);
        chr2 = ((enc2 & 15) << 4) | (enc3 >> 2);
        chr3 = ((enc3 & 3) << 6) | enc4;

        output.append(String.fromCharCode(chr1));

        if (enc3 != 64) {
            output.append(String.fromCharCode(chr2));
        }
        if (enc4 != 64) {
            output.append(String.fromCharCode(chr3));
        }
    }

    return output.toString();
}

//-->
</script>

</head>
<body>
blah
<script type="text/javascript">document.write(d64("PGEgaHJlZj0ibWFpbHRvOnN0ZXZlbkBtYWlsaW5hdG9yLmNvbSI+c3RldmVuQG1haWxpbmF0b3IuY29tPC9hPg=="));</script><noscript>steven[|at|]mailinator[|dot|]com</noscript>
blah
@
@
@
@
@
@
@
@
@@@@@22</body>
</html>

2 个答案:

答案 0 :(得分:1)

未定义StringMaker:

function d64(input) {
    var output = new StringMaker(); //<= what's this?
    ...
}

答案 1 :(得分:0)

我收到了一个javascript错误。 StringMaker未定义。但StringMakerJava相关?