Home / code / javascript

Javascripts script tags,

You can enter JavaScript in a HTML page in 4 different ways

  • JavaScript within the Script-tag
    • With the attribute language in HTML 3.2
      <SCRIPT language="Javascript"></SCRIPT>
      <SCRIPT language="Javascript1.1"></SCRIPT>
      <SCRIPT language="Javascript1.2"></SCRIPT>
      <SCRIPT language="Javascript1.3"></SCRIPT>
    • With the attribute type in HTML 4.0
      <SCRIPT type="text/javascript"></SCRIPT>
    • To hide Javascript for browsers who doesn't support this.
      <SCRIPT type="text/javascript">
      <!-- start hiding
      ...
      // end hiding here -->
      </SCRIPT>


  • Javascript as a external file.
    <SCRIPT src="filename.js"></SCRIPT>

  • JavaScript entities as attributes in HTML
    Javascript entities have a & (ampersand) in front, are between {} and ends with ;
    They can be placed where a HTML-attribute could be placed.
    Example:
    <HR width="&{linelength};">

    As a event handler
    <INPUT NAME="usersname" onblur="validename(this.value)">

  • Adding a default script language in the HEAD (HTML4)
    <META http-equiv="Content-Script-Type" content="text/javascript">

  • Adding a NOSCRIPT-tag for browsers who don't support javascript
    <SCRIPT language="javascript">
    <!-- start
    ...
    // end -->
    </SCRIPT>
    <NOSCRIPT>
    ...
    </NOSCRIPT>

 

TOP

Latest script:

 

Books: