script

Description
Defines a script (programing language), such as JavaScript

Note:Code within this element is executed immediately when the page is loaded, if it is not in a function. Script that appears after a tag will be ignored.

Attributes


Attribute Required Value Description
type yes text/ecmascript
text/javascript
application/ecmascript
application/javascript
text/vbscript
Indicates the MIME type of the script
charset no charset Defines the character encoding used in script
defer no defer Indicates that the script is not going to generate any document content. The browser can continue parsing and drawing th page
language no javascript
livescript
vbscript
Specifies the scripting language. Deprecated. Use the type attribute instead.
src no URL Defines a URL to a file that contains the script (instead of inserting the script into your HTML document, you can refer to a file that contains the script)

Example 1

SourceOutput
<script type="text/javascript">
document.write("Hello World!")
</script>
Hello World!

Source: http://www.w3schools.com/tags/tag_script.asp

Example 2
In this example, we declare the default scripting language to be "text/tcl". We include one SCRIPT in the header, whose script is located in an external file and is in the scripting language "text/vbscript". We also include one SCRIPT in the body, which contains its own script written in "text/javascript".

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<HTML>
<HEAD>
<TITLE>A document with SCRIPT</TITLE>
<META http-equiv="Content-Script-Type" content="text/tcl">
<SCRIPT type="text/vbscript" src="http://someplace.com/progs/vbcalc">
</SCRIPT>
</HEAD>
<BODY>
<SCRIPT type="text/javascript"> ...some JavaScript...
</SCRIPT>
</BODY>
</HTML>

Source: http://www.w3.org/TR/html401/interact/scripts.html


Page Information

  • 11 months ago [history]
  • View page source
  • You're not logged in
  • No tags yet learn more

Wiki Information

Recent PBwiki Blog Posts