【问题标题】:Is there a special meaning for the apostrophe character in htmlhtml中的撇号字符是否有特殊含义
【发布时间】:2021-09-26 04:34:52
【问题描述】:

我在一篇关于字符编码的文章中看到了这段代码 sn-p。

<html>
<body>
<style type="text/css">p {float: left; padding: 0 15px; margin: 0; font-size: 80%;}</style>
<script type="text/javascript">
for (var i=0; i<128; i++) document.writeln ((i%32?’:'<p>') + i + ': ' + String.fromCharCode (i) + '<br>');
</script>
</body>
</html>

该代码应该输出指定范围内的所有 ASCII 字符。 在 for 循环体中,在 writeln 函数中,模条件后面有一个撇号。我不明白撇号是什么意思。我将它复制到我的文本编辑器并将其保存为 HTML 文件,但它不会在我的浏览器上呈现任何内容。它会在控制台Uncaught SyntaxError: Invalid or unexpected token 中产生语法错误。

这是文章的链接 - https://www.smashingmagazine.com/2012/06/all-about-unicode-utf8-character-sets/

【问题讨论】:

    标签: html


    【解决方案1】:

    您也可以像这样使用单字符封闭标签代替撇号。它产生与文章中给出的结果相同的结果,即从 33 到 126。

    for (var i=0; i<128; i++) 
        document.writeln ((i%32?'':'<p>') + i + ': ' + 
            String.fromCharCode (i) + '<br>');
    p {float: left; padding: 0 15px; margin: 0; font-size: 80%;}
    <html>
    <body></body>
    </html>

    【讨论】:

      猜你喜欢
      • 2023-03-27
      • 2015-02-28
      • 2017-09-22
      • 1970-01-01
      • 2013-04-18
      • 2015-05-18
      • 2014-07-29
      相关资源
      最近更新 更多