Archive for the ‘tutorial’ Tag

JavaScript Tutorial: 02

02.html

<html>
<head>
<title>My next script</title>
<script type=”text/javascript” src=”script.js”>
</script>
</head>
<body>

<h1>Hello, World! in HTML</h1>

<h1>
<script type=”text/javascript”>

document.write(“Hello, World! in JavaScript”);

</script>
</h1>

<h1 id=”helloMessage”></h1>
</body>
</html>
************************************************
script.js

window.onload = writeMessage;

function writeMessage() {
document.getElementById(“helloMessage”).innerHTML = “Hello, world! from an external script”;
}
************************************************
Output:

Hello, World! in HTML

Hello, World! in JavaScript

Hello, world! from an external script

JavaScript Tutorial: 01

<html>
<head>
<title>JavaScript Tutorial: 01</title>
</head>
<body>

<h1>Hello, World! in HTML</h1>

<h1>
<script type=”text/javascript”>

document.write(“Hello, World! in JavaScript”);

</script>
</h1>

</body>
</html>

*************************************************

Output:

Hello, World! in HTML

Hello, World! in avaScript