Chapter 1. Adding JavaScript to a Web Page
When JavaScript was first introduced to web pages, Netscape needed to find some mechanism that allowed JavaScript to be added to a web page without causing adverse effects in other browsers. After much debate, it was finally settled on to incorporate the <script/> element, which was later added to the HTML specification.
THE <SCRIPT/> ELEMENT
The primary means of adding JavaScript to a web page is by using the <script/> element. This element, introduced by Netscape, became part of the HTML 3.2 specification as a placeholder for a transition to HTML 4.01, in which the element was fleshed out and given the following attributes:
src: Optional. Specifies an external script file to be executed.type: Required. Specifies the language used in the<script/>element's contents, and a value of"text/javascript"is typically used. Even though this attribute is required by the HTML specification, all browsers assume the language is JavaScript if this attribute is omitted.language: Deprecated. This attribute specifies the language used in the<script/>element's contents. This attribute is no longer used, astypehas replaced it.defer: Optional. A Boolean (trueorfalse) value that tells the browser whether to wait to execute any code within the<script/>element until after the browser loads the entire HTML document.charset: Optional. The character encoding of the external code file specified by thesrcattribute. This attribute is rarely used.
There are ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access