1.<head>
<script type="text/javascript">
document.write("你好JS");
</script>
</head>
<body>
<script type="text/javascript">
document.write("你好JS");
</script>
</body>
JS代码可以放在head中也可以放在Body中,不过执行顺序不同,一般放在head中,代码执行前要先对JS代码进行解析。通时JS代码也可以单独写,然后在HTML页面中进行引用。
2.JS的输出内容
(1)、document.write("i love coding");
(2)、var mystr="hello world!";
document.write(mystr);
(3)、var mystr="hello world!";
document.write(mystr+"Js");
(4)、
<script type="text/javascript">
var mystr="hello";
document.write(mystr+"<br>");
document.write("JavaScript");
</script>
原文:http://www.cnblogs.com/thlpf/p/6475815.html