George_UK George_UK - 2 months ago 6
HTML Question

Simple HTML page not loading Javascript Hello World

As part of a very basic introduction to programming I am instructed to make a simple HTML file with the following code:

<html>

<head>
<title>Simple Page</title>
</head>
<body>
<p>This is a very simple HTML page</p>
<script src="script.js"</script>
</body>




The file is saved as container.html

In the same folder is a file called script.js which contains the following:

alert(“Hello World”);


When I load the HTML file into Safari 7.0.2 it correctly displays "this is a very simple HTML page" and appears to load something but the Javascript alert "Hello World" does not appear in a pop up style window as it does on the instructors computer.

I have checked all settings to make sure Javascript is enabled and popup blocker is off. I've also tried loading in Firefox and Crome but it does not work correctly.

As instructed in the course I am coding using TextEdit and viewing the script through the container.html file.

Answer

You made a mistake

<html>

<head>
    <title>Simple Page</title>
</head>
<body>
    <p>This is a very simple HTML page</p>
    <script src="script.js"></script>
</body>
</html>

You forgot the closing tag on the script.