Topics covered in this snack-sized chapter:

Introduction to JavaScript

Uses of JavaScript

Why to use JavaScript?

Where to use JavaScript

Advantages of JavaScript

Disadvantages of JavaScript

Simple Example of JavaScript Program

Introduction to JavaScript

JavaScript is a programming language that is used to make web pages interactive.

It is programming code that can be inserted into HTML pages.

This scripting language is used for client side scripting.

JavaScript (JS) is a scripting language commonly implemented as part of a web browser in order to create enhanced user interfaces and dynamic websites.

"Brendan Eich" originally developed JavaScript in 1995 at Netscape.

Uses of JavaScript

JavaScript is used to create popup windows and to interact with HTML pages.

JavaScript is used to decrease the code lines.

JavaScript is used for client side scripting for validations.

Mostly JavaScript is used to create, delete or set cookies on page and to retrieve data.

JavaScript’s are mainly used to validate data in the browser. It validates the data before submitted to the server.

JavaScript is used to create dynamic cookies to save temporary files in the browser.

JavaScript saves the processing time on server and decreases latency time as well.

Basically JavaScript is embedded directly in html page.

JavaScript is used to put dynamic text into an HTML page.

Why to use JavaScript?

JavaScript is the most popular language on the web.

Dynamic client-side web applications can be developed using JavaScript.

It is simple yet have powerful core functionality.

It’s easy to implement useful things with JavaScript.

Mostly browsers process JavaScript

You can use it in your own web pages.

You can understand what other web pages are doing and use them if desired.

Where to use JavaScript?

JavaScript can be used in various locations in HTML such as:

In HEAD section.

In BODY section.

In both HEAD and BODY section.

In External Files.

In HEAD section

<html>

<head>

<script type="text/javaScript">

//JavaScript written in HEAD Section

document.write("Welcome to JavaScript HEAD Section.");    

</script>  

</head>

<body>

</body>

</html>

Output: see...monitor

In BODY section

<html>

<head>

</head>

<body>

<script type="text/javascript">

//JavaScript written in BODY Section

document.write("Welcome to JavaScript BODY Section");

</script>

</body>

</html>

Output: see.... monitor

In both HEAD and BODY section

<html>

<head>

<script type="text/javascript">

//JavaScript written in HEAD Section

document.write("Welcome to JavaScript HEAD Section.");

</script>  

</head>

<body>

<script type="text/javascript">

//JavaScript written in BODY Section

document.write("Welcome to JavaScript BODY Section.");

</script>

</body>

</html>

In External File

<html>

<head>

<script src="Myfile.js">

</script>  

</head>

<body>

</body>

</html>

Advantages of JavaScript

Following are the advantages of JavaScript.

JavaScript is simple to learn and implement.

JavaScript is used to display simple alerts to users.

JavaScript validates data on client side.

JavaScript is used for setting and reading cookies, containing data related to a web site.

JavaScript supports cross-browsers.

JavaScript is used to provide a great solution when validating input forms on the client side.

Disadvantages of JavaScript

In JavaScript there is no way to hide JavaScript code in case of commercial applications.

Developer depends on the browser support for JavaScript.

If JavaScript is disabled on browser, it will lead to error or unexpected result on web pages.

Simple Example of JavaScript Program

<html>

<head>

<title>JavaScript First Program</title>

<script language="JavaScript">

function hello()

{

alert("Welcome to WAGmob!");

}

</script>

</head>

<body>

<p>

<b>Click the link below to run first javascript program</b>

</p>

<p><a href="javascript:hello()">Run JavaScript First Program</a>

</p>

</body>

</html>
                                        

Output: ... see monitor


Translate

CR Zaman. Powered by Blogger.

Recent Posts

Popular Posts