问答详情
源自:2-1 JavaScript-输出内容(document.write)

为什么我的代码不能输出结果

<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>document.write</title>
  <script type="text/javascript">
    var mystr="我是";
    var mychar="JavaScript";
document.write(mychar+"<br>");
document.write(mystr+mychar+"的忠实粉丝!");
  </script>
</head>
<body>
</body>
</html>

提问者:weixin_慕侠8435431 2016-10-13 23:56

个回答

  • 废材症患者
    2016-10-14 00:05:30
    已采纳

    document.write(mystr+mychar+"的忠实粉丝!");     这一句的结束符号使用了中文模式

  • qq_等你等到时光都老去_0
    2016-11-03 16:52:34

    为何我的也显示不出预览效果??

  • qq_等你等到时光都老去_0
    2016-11-03 16:52:06

    <!DOCTYPE HTML>

    <html>

    <head>

    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

    <title>document.write</title>

      <script type="text/javascript">

        var mystr="我是";

        var mychar="JavaScript";

    document.write(mychar+"<br>");

    document.write(mystr+mychar+"的忠实粉丝!");

      </script>

    </head>

    <body>

    </body>

    </html>