【发布时间】:2020-02-26 12:00:55
【问题描述】:
我正在编写一个对字符串进行编码的代码,它希望在 div 中显示编码后的字符串。但是,它什么也没显示。我可以知道我的代码有什么问题吗?谢谢。
HTML:
<div id="c"></div>
Javascript:
function encode() {
var a = "abcde";
a = unescape(a);
var c = String.fromCharCode(a.charCodeAt(0) - a.length);
for(var i = 1; i < a.length; i++){
c += String.fromCharCode(a.charCodeAt(i) - c.charCodeAt(i - 1));
}
return c;
document.write(c)
}
【问题讨论】:
标签: javascript html escaping encode