Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
You are here: Reference > HTML > tags > script

script element

Browser support:
Specifies a script block within a HTML document.
The script element allows authors to write or include script codes into HTML documents.
Use the type attribute to specify the language for a script block. If the type attribute is not specified (it was only required in older browsers), JavaScript (JScript) is the basic interpreter for the code.
The script tag should be placed in the head or in the body element.
If you want to see the HTML tags by categories, please visit this page.
This element requires a closing tag.
JavaScript page for this element: script.

Possible members:

Attributes
Events
Styles
charset
Sets the character encoding of the document, a linked document or a script block.
defer
3.5
Sets whether the script is going to generate any document content.
event
Sets an event that the script element should listen for.
for
Sets the identifier of the element to which the script is bound when a specific event is fired for the element.
id
Sets a unique identifier for the object.
lang
Specifies the language of the element.
language
Sets the scripting language for the current element. Use it only for the script element.
name
Sets the name of an element.
src
Sets the location of a file containing scripting code.
type
Sets the type of scripting language to use.

Example HTML code 1:

This example illustrates the use of the script element:
<head>
    <script type="text/javascript">
        window.onload = alert ("Fires onload event.");
    </script>
</head>
Did you find this example helpful? yes no

Example HTML code 2:

This example shows how to link a .js (JavaScript) file into a HTML document:
<head>
    <script type="text/javascript" src="sample.js"></script>
</head>
Did you find this example helpful? yes no

Related pages:

External links:

User Contributed Comments

Post Content

Post Content