JavaScript Scripting language 2011-12. What is Scripting ? A scripting language, script language, or extension language is a programming language.

Slides:



Advertisements
Similar presentations
JavaScript I. JavaScript is an object oriented programming language used to add interactivity to web pages. Different from Java, even though bears some.
Advertisements

1 What is JavaScript? JavaScript was designed to add interactivity to HTML pages JavaScript is a scripting language A scripting language is a lightweight.
JavaScript FaaDoOEngineers.com FaaDoOEngineers.com.
1 CSC 551: Web Programming Spring 2004 client-side programming with JavaScript  scripts vs. programs  JavaScript vs. JScript vs. VBScript  common tasks.
The Web Warrior Guide to Web Design Technologies
EIW: Javascript the Language1 The JavaScript Language.
Outline IS400: Development of Business Applications on the Internet Fall 2004 Instructor: Dr. Boris Jukic JavaScript: Introduction to Scripting.
Working with JavaScript. 2 Objectives Introducing JavaScript Inserting JavaScript into a Web Page File Writing Output to the Web Page Working with Variables.
Javascript Client-side scripting. Up to now  We've seen a little about how to control  content with HTML  presentation with CSS  Javascript is a language.
Tutorial 10 Programming with JavaScript
2012 •••••••••••••••••••••••••••••••••• Summer WorkShop Mostafa Badr
Introduction to JavaScript. Aim To enable you to write you first JavaScript.
Introduction to scripting
Javascript and the Web Whys and Hows of Javascript.
4.1 JavaScript Introduction
JavaScript: Control Structures September 27, 2005 Slides modified from Internet & World Wide Web: How to Program (3rd) edition. By Deitel, Deitel,
WEB DESIGN AND PROGRAMMING Introduction to Javascript.
JavaScript, Fifth Edition Chapter 1 Introduction to JavaScript.
Scripting Languages.
Generations of Programming Languages First generation  Machine Language Second Generation  Assembly Language Third Generation  Procedural language such.
WEEK 3 AND 4 USING CLIENT-SIDE SCRIPTS TO ENHANCE WEB APPLICATIONS.
CNIT 133 Interactive Web Pags – JavaScript and AJAX JavaScript Environment.
Netprog: JavaScript1 JavaScript Client-side dynamic documents.
Week 9 PHP Cookies and Session Introduction to JavaScript.
Client Scripting1 Internet Systems Design. Client Scripting2 n “A scripting language is a programming language that is used to manipulate, customize,
What is Java Script? An extension to HTML. An extension to HTML. Allows authors to incorporate some functionality in their web pages. (without using CGI.
Javascript. Outline Introduction Fundamental of JavaScript Javascript events management DOM and Dynamic HTML (DHTML)
INTRODUCTION TO JAVASCRIPT AND DOM Internet Engineering Spring 2012.
CMPS 211 JavaScript Topic 1 JavaScript Syntax. 2Outline Goals and Objectives Goals and Objectives Chapter Headlines Chapter Headlines Introduction Introduction.
TUTORIAL 10: PROGRAMMING WITH JAVASCRIPT Session 2: What is JavaScript?
Tutorial 10 Programming with JavaScript. XP Objectives Learn the history of JavaScript Create a script element Understand basic JavaScript syntax Write.
Tutorial 10 Programming with JavaScript
Introduction to JavaScript Basharat Mahmood, Department of Computer Science, CIIT, Islamabad, Pakistan. 1.
Using Client-Side Scripts to Enhance Web Applications 1.
 2003 Prentice Hall, Inc. All rights reserved. CHAPTER 3 JavaScript 1.
JavaScript - A Web Script Language Fred Durao
JavaScript Syntax and Semantics. Slide 2 Lecture Overview Core JavaScript Syntax (I will not review every nuance of the language)
XP Tutorial 10New Perspectives on HTML and XHTML, Comprehensive 1 Working with JavaScript Creating a Programmable Web Page for North Pole Novelties Tutorial.
Dr. Qusai Abuein1 Internet & WWW How to program Chap.(6) JavaScript:Introduction to Scripting.
1 JavaScript
JavaScript Syntax, how to use it in a HTML document
JavaScript - Basic Concepts Prepared and Presented by Hienvinh Nguyen, Afshin Tiraie.
JavaScript, Fourth Edition
JavaScript Introduction.  JavaScript is a scripting language  A scripting language is a lightweight programming language  A JavaScript can be inserted.
COMP403 Web Design JAVA SCRİPTS Tolgay KARANFİLLER.
4. Javascript M. Udin Harun Al Rasyid, S.Kom, Ph.D Lab Jaringan Komputer (C-307) Desain.
1 JavaScript in Context. Server-Side Programming.
Pertemuan 5 IT133 Pengembangan Web JavaScript. What is JavaScript? JavaScript was designed to add interactivity to HTML pages JavaScript is a scripting.
Tutorial 10 Programming with JavaScript. 2New Perspectives on HTML, XHTML, and XML, Comprehensive, 3rd Edition Objectives Learn the history of JavaScript.
JavaScript Events Java 4 Understanding Events Events add interactivity between the web page and the user You can think of an event as a trigger that.
Javascript Basic Concepts Presentation By: Er. Sunny Chanday Lecturer CSE/IT RBIENT.
JavaScript Events. Understanding Events Events add interactivity between the web page and the user Events add interactivity between the web page and the.
JavaScript and AJAX 2nd Edition Tutorial 1 Programming with JavaScript.
1 Agenda  Unit 7: Introduction to Programming Using JavaScript T. Jumana Abu Shmais – AOU - Riyadh.
CHAPTER 10 JAVA SCRIPT.
Chapter 6 JavaScript: Introduction to Scripting
“Under the hood”: Angry Birds Maze
JavaScript is a programming language designed for Web pages.
4. Javascript Pemrograman Web I Program Studi Teknik Informatika
JavaScript.
WEB PROGRAMMING JavaScript.
T. Jumana Abu Shmais – AOU - Riyadh
CS105 Introduction to Computer Concepts
Tutorial 10 Programming with JavaScript
“Under the hood”: Angry Birds Maze
Tutorial 10: Programming with javascript
JavaScript Basics What is JavaScript?
JavaScript is a scripting language designed for Web pages by Netscape.
Web Programming– UFCFB Lecture 13
CS105 Introduction to Computer Concepts JavaScript
Presentation transcript:

JavaScript Scripting language

What is Scripting ? A scripting language, script language, or extension language is a programming language that allows control of one or more applications. Scripts are often interpreted from source code or bytecode, whereas the application is typically first compiled to native machine code

What is Client Side Scripting ? Client Side Scripting: Client-side scripting generally refers to the class of computer programs on the web that are executed client-side, by the user's web browser, instead of server-side (on the web server)

Client-Side Scripting Languages Netscape and others – JavaScript Internet Explorer – Jscript (MS name for JavaScript) – VBScript – PerlScript

What is JavaScript JavaScript was designed to add interactivity to HTML pages JavaScript is a scripting language (a scripting language is a lightweight programming language) A JavaScript consists of lines of executable computer code A JavaScript is usually embedded directly into HTML pages JavaScript is an interpreted language (means that scripts execute without preliminary compilation) Everyone can use JavaScript without purchasing a license

Why do we use JavaScript ? Add content to a web page dynamically. Alter a web page in response to user actions. React to user events. Interact with frames. Manipulate HTTP cookies

Features Browser support Detecting user’s browser and OS Can be used on Server as well as Client Performing simple Computation Support objects

Structure of JavaScript program JavaScript Page document.write("Hello world!"); Content of the Page

JavaScript and HTML Comments <!-- document.write(“Hello World"); --> HTML comment

Language Elements Variables Literals Operators Control Structures Objects Arrays

Variables Untyped! Can be declared with var keyword: var foo; Can be created automatically by assigning a value: foo=1; blah="Hi Dave";

Variables (cont.) Using var to declare a variable results in a local variable (inside a function). If you don't use var – the variable is a global variable

Literals(Values) Values are bits of information. Values types and some examples include: – Number: 1, 2, 3, etc. – String: characters enclosed in quotes. “Hi” – Boolean: true or false. – Object: image, form – Function: validate(), doWhatever()

Expressions Expressions are commands that assign values to variables. Expressions always use an assignment operator, such as the equals sign. – e.g., var month = May; is an expression. Expressions end with a semicolon

Operators Arithmetic, comparison, assignment, bitwise, boolean (pretty much just like C). + - * / % == != > < && || ! & | >

Control Structures Again – pretty much just like C: if if-else ?: switch for while do-while And a few not in C for (var in object) with (object)

Function function functionname (Parameter list) { Commands; return value; } The two parts of a JavaScript function are ✦ Parameter list: Defines any data and their data types that the function needs to work. If the function doesn’t need to accept any values, the parameter list can be empty. ✦ Return: Defines a value to return

User-defined functions function definitions are similar to C++/Java, except: – no return type for the function (since variables are loosely typed) – no types for parameters (since variables are loosely typed) – by-value parameter passing only (parameter gets copy of argument) function isPrime(n) // Assumes: n > 0 // Returns: true if n is prime, else false { if (n < 2) { return false; } else if (n == 2) { return true; } else { for (var i = 2; i <= Math.sqrt(n); i++) { if (n % i == 0) { return false; } return true; } can limit variable scope if the first use of a variable is preceded with var, then that variable is local to the function for modularity, should make all variables in a function local

Embedding JavaScript in HTML. When specifying a script only the tags and are essential, but complete specification is recommended: <script language="javascript” type="text/javascript"> <!-- Begin hiding window.location=”index.html" // End hiding script-->

Objects Objects have attributes and methods. Many pre-defined objects and object types. Using objects follows the syntax of C++/Java: objectname.attributename objectname.methodname()

Array Objects Arrays are supported as objects. Attribute length Methods include: Concat() join() pop() push() reverse() sort()

Array example code var a = [8,7,6,5]; for (i=0;i<a.length;i++) a[i] += 2; b = a.reverse();

Many other pre-defined object types String : manipulation methods Math : trig, log, random numbers Date : date conversions RegExp : regular expressions Number : limits, conversion to string

Alert Box An alert dialog box displays a message on the screen and gives the user the option of closing the dialog box. To create an alert dialog box, you need to define the text you want displayed, such as alert(“Message here”); An alert dialog box displays an OK button. As soon as the user clicks this OK button, the alert dialog box goes away

Confirmation Box A confirmation dialog box displays a message and offers the user two or more choices. A confirmation dialog box gives users a choice of OK and Cancel buttons. To create a confirmation dialog box, you must display text and include commandsthat do something when the user clicks either OK or Cancel: if (confirm(“Text message”)) command; else command;

Prompt Box A prompt dialog box gives users a chance to type in data. To create a prompt dialog box, you need to display text to appear in the dialog box and then optional text to appear as a default value, such as prompt(“Text to display”, optionalvalue);

Simple program using JavaScript <!-- function hello() { document.write("Hello,This is JavaScript Output"); } -->

Queries ??