Javascript写入窗口

Javascript写入窗口,javascript,Javascript,如何像在Java中那样使用println在单独的行上打印 <script language = "javascript"> document.write("Your name is:" + fullName); document.write("You were born in:" + birthYear); document.write("You alread

如何像在Java中那样使用println在单独的行上打印

<script language = "javascript">

                    document.write("Your name is:" + fullName);

                    document.write("You were born in:" + birthYear);

                    document.write("You already had your birthday this year");

                    document.write("Your age is an <i>even</i> number.");


        </script> 

写下(“你的名字是:”+全名);
写下(“你出生于:+生日”);
写下(“你今年已经过生日了”);
写下(“你的年龄是一个偶数。”);

您需要以html格式打印数据,因为浏览器是通过这种方式读取数据的。它不像Java中的控制台。要生成多行,应为每行使用段落标记,或在结尾使用打断标记

document.write("<p>Your name is:" + fullName + "</p>");

document.write("Your name is:" + fullName + "<br />");
文档。写(你的名字是:“+fullName+”

”; 文件。写下(“您的名字是:“+fullName+”
);
您可以使用:

document.writeln("...");