Wednesday 24 June 2015

Introduction to JAVASCRIPT

Javascript:

Javascript is one of the scripting languages that can be used along with HTML for validating the inputs of the user.It is used to program the behaviour of the web pages.It can change the html attributes.It can be used to validate inputs.It can even change the HTML stylesheets.

Data types supported by Javascript:
                 
                      Javascript allows you to work with  three built-in datatypes.The data types supported by javascript are:

  1. Numbers
  2. String
  3. Boolean
Defining functions in Javascript :

Syntax:

function name_of_the_function()
{
}

Printing statement in javascript:

                     We can print some statements in javascript using the write function along with the keyword document as document.write("WELCOME");

Popup boxes in javascript:
         
                      We can import dynamism to our sites by adding some elements such as Messageboxes at runtime. For instance, in a Registration form if the user skips the phone number means we can alert the  user by adding the messagebox at runtime. There are two ways to insert the pop up boxes in the webpage.They are:
  • By using alert keyword
  • By using Prompt keyword
Sample program using javascript:

<html>
<head>
<script type="text/javascript" >
function welcome()
{
     alert("Welcome to our webpage");
     document.write("my web page");
}
</head>
<body onload=welcome() >
</body>
</html>

No comments:

Post a Comment