Page 106 - CodePilot V5.0 C8
P. 106
<BODY>
<H1>Hello World!</H1>
<SCRIPT>
alert('Hello World!');
</SCRIPT>
</BODY>
</HTML>
When you click on the OK button, the following output appears:
Note that the alert() function is used to display a pop-up alert with a message.
EXTERNAL JAVASCRIPT
You can write JavaScript code in a separate file, save it with a .js extension and then link it to an
HTML document. To do this, put the file path in the SRC attribute of the <SCRIPT> tag.
The following JavaScript code is used to create the external JavaScript file, named, External.js:
alert('Hello World!');
Code
2 Create a web page to demonstrate the concept of external JavaScript.
<!DOCTYPE HTML>
<HTML>
<HEAD>
<TITLE>External JavaScript</TITLE>
<SCRIPT SRC="External.js">
</SCRIPT>
</HEAD>
<BODY>
<H1>HELLO WORLD!!!</H1>
</BODY>
</HTML>
104
CodePilot (V5.0)-VIII

