JavaScript/Other Script Types

From Wikibooks, open books for an open world
< JavaScript
Jump to: navigation, search
Previous: User:Jesdisciple/JavaScript/Placing the Code Index  

The script element will work in most browsers, because JavaScript is currently the default scripting language. It is strongly recommended though to specify what type of script you are using in case the default scripting language changes.

The scripting language can be specified individually in the script element itself, and you may also use a meta tag in the head of the document to specify a default scripting language for the entire page.

<meta http-equiv="Content-Script-Type" content="text/javascript" />

While the text/javascript was formally obsoleted in April 2006 by RFC 4329 [1] in favour of application/javascript, it is still preferable to continue using text/javascript due to HTML validators' and Internet Explorer web browsers' inability to understand application/javascript [2]

References[edit]

  1. RFC 4329: Scripting Media Types
  2. "application/javascript" and "application/ecmasscript" media types not recognized.


Previous: User:Jesdisciple/JavaScript/Placing the Code Index