Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

like image 424
4 revs Avatar asked Dec 16 '22 00:12

4 revs


1 Answers

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.

like image 185
Max Langerak Avatar answered Feb 09 '23 00:02

Max Langerak