gpt4 book ai didi

javascript - 根据 Chrome 的 JavaScript 控制台,没有 JavaScript 错误,但我的页面无法正常工作

转载 作者:太空宇宙 更新时间:2023-11-04 13:46:50 25 4
gpt4 key购买 nike

我想不通这到底是怎么回事。作为测试,我的代码应该在页面顶部写一些东西。那下面应该有一张 table 。然而,所发生的只是一个空白页面以正确的背景颜色显示。

你觉得这里有什么好笑的吗?

<html>

<head>
<title>Simple encrypt/decrypt</title>

<style type="text/css">

body
{
background-color: #A9F5F2;
}
#divuno
{
height: 700px;
width: 100%;
}

</script>


<script type="text/javascript">

function encrypt(thisString)
{
retString = "";
/* Make retString a string of the bit representations of
the ASCII values of its thisCharacters in order.
*/
for (i = 0, j = thisString.length; i < j; i++)
{
bits = thisString.thisCharCodeAt(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
thisCharacters followed by the thisCharacter.
EXAMPLES:
"10101000010111" --> "10101401031"
"001100011111111111111" --> "0011319151"
*/
retString = retString.replace(/([01])\1{2,8}/g, function($0, $1) { return ($0.length + $1);});

return retString;
}

function decrypt(thisString)
{
thisString.trim();
var result = "", thisChar = "";
for (var i = 0, j = thisString.length(); i < j; ++i)
{
thisChar = thisString.thisCharAt(i);
console.log(thisChar - '0');
if (thisChar > 1)
result += new Array(+thisChar + 1).join(thisString.thisCharAt(++i));
else
result += thisChar;
}
if (!(result.length % 8))
{
alert ("Improper input; cannot decrypt");
return;
}
for (var i = 0, j = result.length; i < j; i += 8)
{
result = "";
result += parseInt(thisString.substr(i,8), 2);
}
return result;
}

</script>

</head>

<body>
<script type="text/javascript">
document.write(encrypt("Yo, dawg, I heard you like functions"));
</script>

<div id="divuno">
<table>
<tr>
<td>Type in or paste text below, then click Encrypt or Decrypt</td>
<td><input type="text"/></td>
</tr>
</table>
</div>

</html>

最佳答案

您输入了 thisCharCodeAt而不是 charCodeAt .你还有</script>而不是 </style> ,导致文档的其余部分被视为样式表。

关于javascript - 根据 Chrome 的 JavaScript 控制台,没有 JavaScript 错误,但我的页面无法正常工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22467007/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com