Home | | Computer Applications 11th std | Using JavaScript in HTML page with 'script' tag

Chapter: 11th Computer Applications : Chapter 14 : Introduction to JavaScript

Using JavaScript in HTML page with 'script' tag

The syntax of JavaScript segment in Hyper Text Markup Language (HTML) or Dynamic Hyper Text Markup Language (DHTML) is as follows:

Using JavaScript in HTML page with <script> tag :

 

JavaScript can be implemented using <script>... </script> tags. The <script> tag containing JavaScript can be placed anywhere within in the web page, but it is normally recommended that should be kept it within the <head> tags. The <script> tag alerts the browser program to start interpreting all the text between these tags as a script commands.

The syntax of JavaScript segment in Hyper Text Markup Language (HTML) or Dynamic Hyper Text Markup Language (DHTML) is as follows:

 

<script language="javascript" type="text/javascript">

JavaScript code

</script>

 

The <SCRIPT> tag takes two important attributes −

Language − This attribute specifies that the scripting language. Typically, its value will be javascript. Although recent versions of HTML (EXtensible HyperText Markup Language - XHTML, its successor) have phased out the use of this attribute is optional.

Type − This attribute is used to indicate the scripting language and its value should be set to "text/javascript".

 

Steps to follow to code JavaScript Language

 

         Enter HTML and JavaScript code using any text editor.

 

         Save the latest version of this code.

 

         Use any browser to see the result. For example : Internet Explorer, Google Crome, etc.,

 

         If this is a new document, open the file via browser's Open Menu. If the document is already loaded in the Memory, to reload the file into the browser use "Refresh" or press F5 button.

 

First JavaScript Program

 

Illustration 14.1 Simple JavaScript Program

<Html>

<Head>

<Title>My First JavaScript Program</Title>

<script language="javascript" type="text/javascript">

        document.write("Hello World!")

</script>

</Head>

<Body>

</Body>

</Html>

Output:


 

Study Material, Lecturing Notes, Assignment, Reference, Wiki description explanation, brief detail
11th Computer Applications : Chapter 14 : Introduction to JavaScript : Using JavaScript in HTML page with 'script' tag |


Privacy Policy, Terms and Conditions, DMCA Policy and Compliant

Copyright © 2018-2024 BrainKart.com; All Rights Reserved. Developed by Therithal info, Chennai.