Difference between revisions of "Embedding JavaScript into Web pages"

From Techotopia
Jump to: navigation, search
(New page: Now that we have looked at the history of JavaScript and tried some simple example JavaScript code it is time to explore the mechanisms for including JavaScript into web pages. = The <scr...)
 
(The <script> element)
Line 4: Line 4:
  
 
JavaScript is embedded into HTML and XHTML documents using the ''<script>'' element. This element can be used to embed the javaScript directly into the web page, or to specify an external file that contains the JavaScript.
 
JavaScript is embedded into HTML and XHTML documents using the ''<script>'' element. This element can be used to embed the javaScript directly into the web page, or to specify an external file that contains the JavaScript.
 +
 +
The ''<script>'' element is used with a number of attributes:
 +
 +
* '''defer''' - used to inform the browser that the script associated with this ''<script>'' element generates content (in otehr words the document.write() method is used). This can be either ''true'' or ''false''. The default setting (i.e if this is not specified) is ''false''.

Revision as of 19:31, 9 April 2007

Now that we have looked at the history of JavaScript and tried some simple example JavaScript code it is time to explore the mechanisms for including JavaScript into web pages.

The <script> element

JavaScript is embedded into HTML and XHTML documents using the <script> element. This element can be used to embed the javaScript directly into the web page, or to specify an external file that contains the JavaScript.

The <script> element is used with a number of attributes:

  • defer - used to inform the browser that the script associated with this <script> element generates content (in otehr words the document.write() method is used). This can be either true or false. The default setting (i.e if this is not specified) is false.