Page 289 - Web Applications (803) Class 11
P. 289

</SCRIPT>
                   </BODY>
                   </HTML>
                 The TYPE attribute of the <SCRIPT> tag is used to specify the language of the script. In this case, we have used the "text/
                 javascript" value. Some other values of the TYPE attribute are "text/css" and "text/vbscript". However, it is optional to
                 use the TYPE attribute in the case of JavaScript as "text/javascript" is the default value of it.
                 In HTML, we can use JavaScript in two ways internally and externally.
                 Internal JavaScript

                 When JavaScript code is written within the HTML web page then it is called internal JavaScript. We use the <SCRIPT>
                 and </SCRIPT> tags to place the JavaScript code either in the <HEAD> or <BODY> tag of the HTML document. The
                 syntax to add internal JavaScript is:

                   <HEAD>
                   <SCRIPT>
                   JavaScript code
                   .....
                   </SCRIPT>
                   <HEAD>
                   OR
                   <BODY>
                   <SCRIPT>
                   JavaScript code
                   .....
                   </SCRIPT>
                   </BODY>
                 Creating a Web Page with Internal Javascript

                 Similar to HTML web page, we can use any text editor like Notepad, Visual Studio Code, Sublime Text, etc. to create
                 JavaScript programs. After typing the JavaScript code, any web browser like Google Chrome, Firefox, Microsoft Edge,
                 etc. are used to view the web page. Let us create a web page using internal JavaScript.

                 Follow the given steps to create a JavaScript program:
                 Step 1:  Type <script type = “text/JavaScript”> between the <HEAD> and </HEAD> tags to use JavaScript.
                 Step 2:  Use the alert() method to display virtual alert box that contains some specified message and an OK button.

                         <HTML>
                         <HEAD>
                         <TITLE> My First JavaScript </TITLE>
                         <SCRIPT TYPE="text/javascript">
                         alert("Hello World!");
                         </SCRIPT>
                         </HEAD>
                         <BODY>
                         This message box is displayed using JavaScript.

                         </BODY>
                         </HTML>


                                                                      Introduction to Dynamic Websites Using JavaScript  287
   284   285   286   287   288   289   290   291   292   293   294