CoderTools Web site

HTML Script Tag - <script>


Description


The Script tag allows you to add client side script to the page. The Script tag is placed in the head tag or within the body tag. You can have many script tags in a page.

You can use script to validate forms, manipulate parts of the page, change colours, respond to events on the page e.g. clicking an image. You are limited only be your imagination and browser compatibility!

Examples

Example 1:
        <script type="text/javascript">
            alert('hi from script');
        </script>Give it a go!
Example 2:
        <script type="text/javascript">
            function textrollover()
            {
                alert('you moved your mouse over the text');
            }
        </script>
        
        <span onmouseover="javascript:textrollover()">
            Move your mouse over this text
        </span>Give it a go!
Example 2:

Move your mouse over this text


Attributes


Name Values Description
type content type e.g. text/javascript
text/vbscript
The type attribute specified the content type of the client side script. Scripts can be written in many languages this attribute tells the browser which one.
type content type e.g. text/javascript
text/vbscript
The type attribute specified the content type of the client side script. Scripts can be written in many languages this attribute tells the browser which one.
src url You can put your scripts in a seperate file. This is useful when you have a script used in many html pages you can use the src attribute to point to a single file so any script changes can be made in only one place.

8/17/2017 8:24:00 PM
Terms Of Use | Privacy Statement | Copyright 2006-2015 © Independence Software LLP