HTML - Javascript scripts

JavaScript and Vbscript are often used in a HTML page code to give more interactivity to the page, or just for one of the many applications of these scripts.

Using these scripts you can create interactiv animations for images, animated menus with amazing effects and so on. Also, one of the most important applications is that of validating a form before sending it. This will make the user spend considerably less time in the case the user has wrongly completed the fields, and a reload of the page being needed.

In this part we will only talk about the method of inserting the script into HTML

Note: Most of the time it is much easier to just download from the internet than to write these scripts. Of course, that is possible only if the author has given his/her agreement for personal and/or comercial use. There are also a variety for javascript libraries that are free to use.

Inserting JavaScript in HTML

Inserting a javascript code is done very easily using the script tag. Here is an example:

html<script type="text/javascript">

/* Here will be the the javascript code */


For the javascript codes the 'text/javascript' value will be given to the type attribute.

Inserting Vbscript in HTML

Inserting a vbscript code is done in the same way as the javascript code is done, only that you replace the 'text/javascript' with 'text/vbscript'. Here is the example:

html<script type="text/vbscript">

/* Here will be the the javascript code */


It is always recommended to insert a comment along with the javascript and vbscript codes. That will warn the browsers that do not support that kind of script, or browsers that have javascript and vbscript disabled.