Basic HTML knowledge is recommended. Click here to go to the HTML collection.
- In an external file
- In form of an HTML-link
- As a parameter of an HTML-tag
We use the following command as an example:
Our example will display the text: "hello js".
After being interpreted by a browser, this code is equivalent to the following code:
If you run this or any of the other examples in Microsoft Internet Explorer (IE9-), you'll get a warning message. So you have to click a few times, until the code is executed. There are two antidotes:
- You can install a local server and access the examples through the web server.
- You can activate the checkbox at
Menu Tools => Internet Options => Advanced => Security => "Allow active content to run in files on my computer"
In XHTML or HTML 4 the
type-attribute was required. This is a newer alternative to
Here's an example:
In HTML 5 this attribute isn't important anymore.
It's your decision whether you use it or not. For older browsers, the
type-attribute is recommendable.
/* and */Displays a multiline comment. Everything between
Continue to part 2