当前位置: 代码迷 >> JavaScript >> write()跟writeln()的区别,为什么在浏览器中显示一样
  详细解决方案

write()跟writeln()的区别,为什么在浏览器中显示一样

热度:81   发布时间:2013-04-20 19:43:01.0
write()和writeln()的区别,为什么在浏览器中显示一样
write()和writeln()的区别是什么?
writeln()为什么不换行
write()

------解决方案--------------------
document.writeln("just");
document.write("a");
document.write("test");
貌似只插入了一个空格的样子
------解决方案--------------------
document.writeln("aaa");
等于
document.write("aaa"+"\n");
------解决方案--------------------
html是忽略换行符(\n)的,除非是在<pre></pre>中
<pre>
<script type="text/javascript">
document.writeln("A");
document.write("B");
document.write("C");
</script>
</pre>
  相关解决方案