Simple HTML page not loading Javascript Hello World

As part of a very simple 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 upload an HTML file in Safari 7.0.2, it correctly displays “this is a very simple HTML page” and seems to load something, but the Javascript “Hello World” warning does not appear in the style popup because it is on the instructors computer .

I checked all the settings to make sure Javascript is turned on and the pop-up blocker is turned off. I also tried downloading in Firefox and Crome, but it does not work correctly.

, TextEdit script container.html.

+4
8

<html>

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

script.

+4

, <script>.

,

<script src='http://code.jquery.com/jquery-latest.min.js'></script> //to include jQuery
<script src="script.js"></script>

" " " '.

.

, ready:

$(document).ready(function(){
  alert("Hello World");
});
+4

' script

:

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

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

" > "

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

, script ( HTML- ):

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

.

0

script!

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

html

<html>

<head>
    <title>Simple Page</title>
    <script src="http://code.jquery.com/jquery-1.9.0.js"></script>
</head>
<body>
    <p>This is a very simple HTML page</p>
    <script src="script.js"></script>
</body>

Your js

$(document).ready(function (){
    alert("Hello world");
});
0
source

Source: https://habr.com/ru/post/1533910/


All Articles