javascript basics

16
JAVASCRIPT Presented By :- Vishal 15- CSE-2835

Upload: vishal-mittal

Post on 09-Apr-2017

13 views

Category:

Engineering


0 download

TRANSCRIPT

Page 1: Javascript Basics

JAVASCRIPT

Presented By :- Vishal 15-CSE-2835

Page 2: Javascript Basics

Content• What is JavaScript ?• History & Versions• JavaScript Over Java• Elements of JavaScript• Applications • Advantages• Cautions

Page 3: Javascript Basics

What is JavaScript ?

• JavaScript is the programming language for HTML and the Web.

• It is similar to C language.

Page 4: Javascript Basics

History

• First web scripting language.• It was developed by Netscape & Sun.• The first version of the Web browser, Mosaic

Netscape 0.9, was released in late 1994.

Page 5: Javascript Basics

VersionsVersion Release Supported

Browser1.0 March 1996 Netscape 21.1 August 1996 Netscape 31.2 June 1997 Netscape 41.3 October 1998 Netscape 4.061.5 November 2000 Netscape 61.6 November 2005 Firefox 1.51.7 October 2006 Firefox 21.8 June 2008 Firefox 31.8.1 2009 Firefox 3.51.8.2 June 22, 2009 Firefox 3.61.8.5 July 27, 2010 Firefox 4

Page 6: Javascript Basics

HTML, CSS & JAVASCRIPT

JavaScript is one of the 3 languages all web developers must learn:

•    1. HTML to define the content of web pages

•    2. CSS to specify the layout of web pages

•    3. JavaScript to program the behavior of web pages

Page 7: Javascript Basics

JavaScript Over Java

Java JavaScript1.) Java is an OOP programming language

1.) Java Script is an OOP scripting language

2.) Java codes is run in a virtual machine or browser

2.) JavaScript code is run on a browser only

3.) Java code needs to be compiled

3.) JavaScript code are all in text

Page 8: Javascript Basics

Elements of JavaScript

• Variables

• Arrays

• Functions

Page 9: Javascript Basics

Variables<script language=“JavaScript”>

<!-- definition of variables-->

var num_car= 25;

var passenger_per_car= 3;

//calculation of total number of people

var total_passenger= num_car * passenger_per_car

Alert(total_passenger);

// end of script -->

</script>

Page 10: Javascript Basics

Arraysvar score = new Array(3);

score[0] = 35;score[1] = 56;score[2] = 10;

sum=score[0]+score[1]+score[2];

alert(sum) ;

Page 11: Javascript Basics

Function<html>

<head>

<script langauge="JavaScript">

<!-- hide me

function announceTime( ) { //get the date, the hour, minutes, and seconds

var the_date = new Date();

var the_hour = the_date.getHours();

var the_minute = the_date.getMinutes();

var the_second = the_date.getSeconds(); //put together the string and alert with it

var the_time = the_hour + ":" + the_minute + ":" + the_second;

alert("The time is now: " + the_time); } // show me -->

</script>

Page 12: Javascript Basics

Cont…

</head>

<body>

<h3>Click the button to get current Date and time</h3>

<input type="button" value=“Show Date" onclick=“announceTime()“/>

</body>

</html>

Page 13: Javascript Basics

Applications• Show slideshow of Images• Show dropdown menu• Data checking in forms in client side• Pop ups in web pages• Auto pages refresh after a certain time

Page 14: Javascript Basics

Advantages

• JavaScript is executed on the client side.• JavaScript is a relatively easy language.• JavaScript is relatively fast to the end user.• Extended functionality to web pages.

Page 15: Javascript Basics

•JavaScript is very case sensitive•Use separate lines for each command•Be careful with parenthesis and quotes•Use single quotes within double quotes•Use a semi-colon after commands as shown in examples

Cautions...

Page 16: Javascript Basics

Thanks…