Basics #3 Importing from JS JavaScript File

1.Creating a new JS file.

Right-click and choose "new file" and type the file name "script.js".

2.Linking to the HTML file

Switch to index.html.Before</body>insert

<script src="script.js"></script>

3.Add some JavaScript scripts

Switch to script.js.Add some scripts for example

alert("Hello World");

4.Viewing in Browser

Double-click the HTML file,or open a browser and drag the file into the browser.

>> Next lesson >>