TOC
wwworkshop
Uni Köln

3.1
A first script

  1. In your project directory, create a new file and call it script.js.

  2. The script file has to be included in the HTML structure with the script tag. The script tag should be added at the very end of the body tag (after every other tag inside body, just before </body>).

  3. Add the code to script.js.

When you open the web page you should see a dialog display the text.

???

The first line creates a variable called text and assigns the text wwwow! to it.

The second line calls a function called alert and passes the variable as an argument.

index.html

<html>
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Titel</title>
</head>
<body>
    <script src="script.js"></script>
</body>
</html>

script.js

let text = 'wwwow!'
alert(text)