我的网页应该打印出一串数字,但isn'
My webpage should be printing out a string of digits, but isn't
知道为什么下面的代码不能工作吗?它应该创建一个网页,只是一串数字(通过一个可逆的加密方案,你可以在函数encrypt()
中看到)。然而,所发生的一切是document.write(encrypt("Yo, dawg, I heard you like functions"));
被打印在网页的顶部。
<html>
<head>
<title>Simple encrypt/decrypt</title>
<script type="text/javascript">
function encrypt(thisString)
{
retString = "";
/* Make retString a string of the bit representations of
the ASCII values of its characters in order.
*/
for (i = 0, j = thisString.length; i < j; i++)
{
bits = thisString.charCodeAt(i).toString(2);
retString += new Array(8-bits.length+1).join('0') + bits;
}
/* Compress retString by taking each substring of 3, 4, ..., 9
consecutive 1's or 0's and it by the number of such consecutive
characters followed by the character.
EXAMPLES:
"10101000010111" --> "10101401031"
"001100011111111111111" --> "0011319151"
*/
retString.replace(/([01])'1{2,8}/g, function($0, $1) { return ($0.length + $1);});
return retString;
}
</script>
</head>
<body>
<script="text/javascript">
document.write(encrypt("Yo, dawg, I heard you like functions"));
</script>
</body>
</html>
打字错误:
<script="text/javascript">
应该<script type="text/javascript">
相关文章:
- 如何将返回一串数字的 JSON 属性转换为日期
- 在一串数字中查找特定值
- 如何将一串数字转换为数组
- javascript对象(如array&一串
- 如何用Javascript生成一串数字和字母
- 加载一串 markdown 属性作为 JavaScript 对象
- 为什么一串数字的工作方式与新日期中的实际数字不同
- 如何将一串数字和数学运算符变成整数答案?- JavaScript
- 传给玉的东西最后是一串
- 色调转换一串颜色
- 如何在饼干中剪下一串字母
- 如何用'null'一串
- 是 JavaScript 中的一串空白真或假
- Node JS -在一个新进程中执行一串代码
- 有没有任何字符串方法,能让我把一串数字,转换成一串数字和字母
- 一串没有RegEX的Match()
- 对一串数字进行排序,每个数字里面都有一个字母.确保在原始数组中保持相同的重复项位置
- 在javascript中创建一串数字,每个数字都有限制
- Javascript过程解压缩一串十进制数字
- 我的网页应该打印出一串数字,但isn'