This tutorial will teach you how to use JS (JavaScript) to create more dynamic and more user interactive websites.

Before learning JS it is important to be familiar with the HTML and CSS already, as in the web design HMTL elements and their styles are those that scripts are being applied on.

There are 3 ways of adding JS to your web page:

  • inline;
  • internal;
  • external.

The inline scripts are applied directly on HMTL elements and their principles are better explained in the HTML tutorial. However in this tutorial inline scripting, due their simplicity, will be used as well.

The internal and external ways of scripting are almost. The difference amongst them is that internal scripts are added somewhere inside the HTML document and are placed between HTML tags <script></script>, while the external scripts have the code written in another file with the ".js" extension and are evoked with the HTML element <script type="text/javascript" />JS code</script>.

The external JS is by far the suggested way of scripting your web pages because it offers a complete separation between content (HTML), styling (CSS) and client side scripting (JS), and thus simplifying maintenance and upgrades of a website.

Important note regarding the scripts is that acceptance of the standards sometimes depends on a particular browser; i.e. older browsers (especially Internet explorer) have tendency not to understand certain JS standards or suggestions.

Examples

Each chapter has attached an interactive example that can be easily modified and tested as wanted.

For the purpose of simplicity many examples are written with internal scripts, instead of being imported from an external file as it is suggested.

All examples can be found at the end of the tutorial.

›› go to examples ››

References

At the end of the tutorial you will find a complete reference list with data types, operators, statements, functions, etc...

›› go to references ››