JavaScript in <body>
The example below writes the current date into an existing <p> element when the page loads:
Example
<html>
<body>
<h1>My First Web Page</h1>
<p id="demo"></p>
<script type="text/javascript">
document.getElementById("demo").innerHTML=Date();
</script>
Edit and click Me>>>
<html>
<body>
<h1>My First Web Page</h1>
<script type="text/javascript">
document.write("<p>" + Date() + "</p>");
</script>
</body>
</html>
your result
My First Web Page
Wed Feb 23 01:53:10 2011
</body>
</html>
The example below writes the current date into an existing <p> element when the page loads:
Example
<html>
<body>
<h1>My First Web Page</h1>
<p id="demo"></p>
<script type="text/javascript">
document.getElementById("demo").innerHTML=Date();
</script>
Edit and click Me>>>
<html>
<body>
<h1>My First Web Page</h1>
<script type="text/javascript">
document.write("<p>" + Date() + "</p>");
</script>
</body>
</html>
your result
My First Web Page
Wed Feb 23 01:53:10 2011
</body>
</html>