</html>
-----------------------------------------------------------------------------------------------------------------------
-----------------------------------------------------------------------------------------------------------------------
<!DOCTYPE html>
<html>
<meta http-equiv="Content-Type" content="text/html;charset=utf-8"/>
<head>
<title></title>
</head>
<center>
<body>
<script>
document.write("<h1>This is my first Java Script</h1>");
document.write("<p>Come with me!</p>");
</script>
</body>
</center>
</html>
-----------------------------------------------------------------------------------------------------------------------
-----------------------------------------------------------------------------------------------------------------------
head 中的 JavaScript 函数<!--
<head> 中的 JavaScript 函数
在本例中,我们把一个 JavaScript 函数放置到 HTML 页面的 <head> 部分。
该函数会在点击按钮时被调用:
-->
<!--<button type="button" onclick="myFunction()">Try it</button>
在函数调用的过程中将函数的名称写错
-->
<!DOCTYPE html>
<html>
<center>
<meta http-equiv="Content-Type" content="text/html charset=utf-8"/>
<head>
<script>
function myFunction()
{
document.getElementById("demo").innerHTML="My First JavaScript Function";
}
</script>
</head>
<body>
<h1>My Web Page</h1>
<p id="demo">A Paragraph</p>
<button type="button" onclick="myFunction()">Try it</button>
</body>
</center>
</html>
JavaScript-body 中的 JavaScript 函数\head 中的 JavaScript 函数
原文:http://blog.csdn.net/u012701023/article/details/46234649