Quick References
      ADO
      ASP
      CSS2
      HTML
      JavaScript
      Jet SQL
      VBScript
      WML
      WMLScript
      WSH
      XHTML
      XML DOM
      XSLT

Features
      Knowledge Base
      Tutorials

Partners
     ZVON.ORG
     XML
     Planet Source Code
     VisualBuilder
     Web Design
     Your HTML Source
     XML/XSLT Forums
     ASPAlliance
     Scripts
     
     Programmers Heaven
     Tek-Tips Forums
     Developer Fusion
     Code Project









TAG:  script

<script> ... </script>
 
The script tag is used to place script code inside the head and body elements of an HTML code document. For all practical purposes, this tag is primarily used to allow the execution of JavaScript code inside HTML code (and, to a lesser extent, VBScript).
 
The separate closing tag is mandatory.
 
Attributes and Events
 
charset
The charset attribute is used to define the character set that was used to write the script.
 
defer
The defer attribute informs the server that the script will not alter the contents of the page on the server-side. This is intended to allow the server to load the page faster. (In JavaScript, this means no document.write statements.)
 
src
The src attribute is the URL of a file that contains a script code. This is useful when you need to use repeatedly a long script program. The browser will load and execute the script as a separate file.
 
type
The mandatory type attribute is used to define the script language being used. Permitted values include text/css, text/javascript, and text/vbscript. There is no default value.
 
This example uses the script tag to place a JavaScript function in the head element to see if two form fields (firstname and lastname) have been left blank. The form portion of the code is not included, but may be viewed on the form tag page.
 
Code:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title>DevGuru JavaScript Example</title>
<script type="text/javascript">
<!--
function checksubmit()
{
   if (document.formname.firstname.value == "")
   {
      alert("Please enter your full name")
      document.formname.firstname.focus()
      return false
   }
   if (document.formname.lastname.value == "")
   {
      alert("Please enter your email address")
      document.formname.lastname.focus()
      return false
   }
   return true
)
-->
</script>
</head>
<body>
... form goes here ...
</body>
</html>


Output:
Click to view and test the form in separate window


 


Copyright 1999-2005 by Infinite Software Solutions, Inc. All rights reserved.
Trademark Information