Next page | Contents page |

The <script> element

We are going to write a program in a language called Javascript. It will be in a separate file called game.js (for now). This file will be in the same folder (directory) as the HTML file but we need to add another element at the end of the HTML body, after the <canvas>:


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

src simply means source. The value of this attribute could be the path to the file. In larger projects we might well put Javascript files in a subdirectory, perhaps called js.

There are other ways to include some Javascript into an HTML page but this is the simplest.

Javascript is a fully-fledged and powerful programming language. When running in a browser, as here, it has some restrictions on the grounds of security. The main restriction is that it cannot browse your local files and directories. It is possible to use it to upload and download files but only when the user identifies the particular files.
Next page | Contents page |