Scripting Languages.

Slides:



Advertisements
Similar presentations
Chapter 7 JavaScript: Introduction to Scripting. Outline Simple Programs Objects and Variables Obtaining User Input with prompt Dialogs – –Dynamic Welcome.
Advertisements

JavaScript I. JavaScript is an object oriented programming language used to add interactivity to web pages. Different from Java, even though bears some.
Intro to Javascript CS Client Side Scripting CS380 2.
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
Outline IS400: Development of Business Applications on the Internet Fall 2004 Instructor: Dr. Boris Jukic JavaScript: Introduction to Scripting.
CS 299 – Web Programming and Design Overview of JavaScript and DOM Instructor: Dr. Fang (Daisy) Tang.
2012 •••••••••••••••••••••••••••••••••• Summer WorkShop Mostafa Badr
Introduction to JavaScript for Python Programmers
Introduction to JavaScript. Aim To enable you to write you first JavaScript.
CST JavaScript Validating Form Data with JavaScript.
4.1 JavaScript Introduction
WEB DESIGN AND PROGRAMMING Introduction to Javascript.
Chapter 5 Java Script And Forms JavaScript, Third Edition.
 2003 Prentice Hall, Inc. All rights reserved. CHAPTER 3 JavaScript 1.
JavaScript Defined DOM (Document Object Model) General Syntax Body vs. Head Variables Math & Logic Selection Functions & Events Loops Animation Getting.
SEG3210 DHTML Tutorial. DHTML DHTML is a combination of technologies used to create dynamic and interactive Web sites. –HTML - For creating text and image.
CNIT 133 Interactive Web Pags – JavaScript and AJAX JavaScript Environment.
DHTML: Dynamic HTML Internet Technology1. What is DHTML? A collection of enhancements to HTML ► To create dynamic and interactive websites Combination.
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)
Objective Static vs. Dynamic Web pages. Variables. Assignments. JavaScript Hierarchy of Objects JavaScript Functions (prompt(“”,””) Document.write(“”)
INTRODUCTION TO JAVASCRIPT AND DOM Internet Engineering Spring 2012.
JavaScript, Fourth Edition Chapter 5 Validating Form Data with JavaScript.
 2003 Prentice Hall, Inc. All rights reserved. CHAPTER 3 JavaScript 1.
Client-Side Scripting JavaScript.  produced by Netscape for use within HTML Web pages.  built into all the major modern browsers. properties  lightweight,
Lecture 9 The Basics of JavaScript Boriana Koleva Room: C54
Introduction.  The scripting language most often used for client-side web development.  Influenced by many programming languages, easier for nonprogrammers.
JavaScript - A Web Script Language Fred Durao
VBScript. Introduction Visual Basic scripting language is client side scripting language. It is developed by Microsoft VBScript is subset of VB language.
JS Basics 1 Lecture JavaScript - Basics. JS Basics 2 What is JavaScript JavaScript is a “simple”, interpreted, programming language with elementary object-
JavaScript Adding active content to websites. Goals Understand structure of JavaScript Understand rules of coding Add active content to WebPages Add functions.
Dr. Qusai Abuein1 Internet & WWW How to program Chap.(6) JavaScript:Introduction to Scripting.
1 JavaScript
JavaScript - Basic Concepts Prepared and Presented by Hienvinh Nguyen, Afshin Tiraie.
JavaScript Scripting language What is Scripting ? A scripting language, script language, or extension language is a programming language.
JavaScript, Fourth Edition
JavaScript Introduction.  JavaScript is a scripting language  A scripting language is a lightweight programming language  A JavaScript can be inserted.
4. Javascript M. Udin Harun Al Rasyid, S.Kom, Ph.D Lab Jaringan Komputer (C-307) Desain.
Javascript JavaScript is what is called a client-side scripting language:  a programming language that runs inside an Internet browser (a browser is also.
JavaScript Defined DOM (Document Object Model) General Syntax Body vs. Head Variables Math & Logic Selection Functions & Events Loops Animation Getting.
CIS 3.5 Lecture 2.3 "Introduction to JavaScript".
Introduction to JavaScript. Introduction What is it? How does it work? What is Java? Learning JavaScript JavaScript Statements JavaScript and HTML forms.
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.
The Magic of Dynamic Web Pages Doncho Minkov Telerik Software Academy academy.telerik.com Technical Trainer
The Magic of Dynamic Web Pages Telerik Software Academy JavaScript Fundamentals.
1 Agenda  Unit 7: Introduction to Programming Using JavaScript T. Jumana Abu Shmais – AOU - Riyadh.
JavaScript: A short introduction Joseph Lee Created by Joseph Lee.
Web Programming Java Script-Introduction. What is Javascript? JavaScript is a scripting language using for the Web. JavaScript is a programming language.
Client-side (JavaScript) Validation. Associating a function with a click event – Part 1 Use the input tag’s onclick attribute to associate a function.
Chapter 4 Java Script – Part2. 2 Location object Properties Properties href – whole path will be displayed. ex: window.location.href ( see example 11)
Introduction to.
LECTURE 6 (ETCS-308) Subject teacher : Ms. Gunjan Beniwal
Chapter 5 Validating Form Data with JavaScript
>> Introduction to JavaScript
CHAPTER 10 JAVA SCRIPT.
Applied Component I Unit II Introduction of java-script
CIIT-Human Computer Interaction-CSC456-Fall-2015-Mr
JavaScript is a programming language designed for Web pages.
WEB APPLICATION PROGRAMMING
4. Javascript Pemrograman Web I Program Studi Teknik Informatika
JavaScript.
Tutorial 10: Programming with javascript
JavaScript Basics What is JavaScript?
JavaScript is a scripting language designed for Web pages by Netscape.
Presentation transcript:

Scripting Languages

Scripting Languages Client Side Scripting Languages Server side Scripting Languages

JavaScript Browsers have limited functionality Text, images, tables, frames JavaScript allows for interactivity Browser/page manipulation Reacting to user actions A type of programming language Easy to learn Developed by Netscape

JavaScript Allows Interactivity Improve appearance Especially graphics Visual feedback Site navigation Perform calculations Validation of input Other technologies

JavaScript Allows Interactivity

How Does It Work? Embedded within HTML page Executes on client View source Executes on client Fast, no connection needed once loaded Simple programming statements combined with HTML tags Interpreted (not compiled) No special tools required

JavaScript is different from Java A full programming language Much harder! A compiled language Independent of the web Sometimes used together

Simple JavaScript Example <html> <head><title>My Page</title></head> <body> <script language="JavaScript"> document.write(‘This is my first JavaScript Page’); </script> </body> </html>

More Example <html> <body> <script type="text/javascript"> alert('Hello JavaScript!'); </script> </body> </html>

Using Java Script code The JavaScript code can be placed in: <script> tag in the head <script> tag in the body – not recommended External files, linked via <script> tag the head Files usually have .js extension <script src="scripts.js" type="text/javscript"> <!–- code placed here will not be executed! --> </script>

JavaScript – When is Executed? JavaScript code is executed during the page loading or when the browser fires an event All statements are executed at page loading Some statements just define functions that can be called later Function calls or code can be attached as "event handlers" via tag attributes Executed when the event is fired by the browser <img src="logo.gif" onclick="alert('clicked!')" />

The JavaScript Syntax The JavaScript syntax is similar to C# and Java Operators (+, *, =, !=, &&, ++, …) Variables (typeless) Conditional statements (if, else) Loops (for, while) Arrays (my_array[]) and associative arrays (my_array['abc']) Functions (can return value) Function variables (like the C# delegates)

Data Types JavaScript data types: String type – string of characters Numbers (integer, floating-point) Boolean (true / false) String type – string of characters Arrays Associative arrays (hash tables) var myName = "You can use both single or double quotes for strings"; var my_array = [1, 5.3, "aaa"]; var my_hash = {a:2, b:3, c:"text"};

Everything is Object Every variable can be considered as object For example strings and arrays have member functions: var test = "some string"; alert(test[7]); // shows letter 'r' alert(test.charAt(5)); // shows letter 's' alert("test".charAt(1)); //shows letter 'e' alert("test".substring(1,3)); //shows 'es' var arr = [1,3,4]; alert (arr.length); // shows 3 arr.push(7); // appends 7 to end of array alert (arr[3]); // shows 7

String Operations The + operator joins strings What is "9" + 9? Converting string to number: string1 = "fat "; string2 = "cats"; alert(string1 + string2); // fat cats alert("9" + 9); // 99 alert(parseInt("9") + 9); // 18

Arrays Operations and Properties Declaring new empty array: -var arr = new Array(); Declaring an array holding few elements: -var arr = [1, 2, 3, 4, 5]; Adding & removing an element: -arr.push(3); -var element = arr.pop(); Reading the number of elements (array length): -arr.length;

Standard Popup Boxes Alert box with text and [OK] button Just a message shown in a dialog box: alert("Some text here"); Confirmation box Contains text, [OK] button and [Cancel] button: confirm("Are you sure?"); Prompt box Contains text, input field with default value: prompt ("enter amount", 10);

JavaScript Built-in objects String Object Date Object Array Object Math Object Boolean Object

String Object Methods big()-displays a string in big font Blink()- displays a blinking string Bold()- displays a string in bold Concat()- joins two or more strings Fontcolor() charAt() Fontsize() Italics() Link() Replace()

String Object Methods 11. search() 12. split() 13. small() 14. strike() 15. sub() 16.sup() 17. substring() 18. toUpperCase() 19. toLowerCase()

Date Object Methods Date() getDate() getDay() getMonth() getYear() getHours() getMinutes() getSeconds()

Date Object Methods 9. getMilliseconds() 10. setDate() 11. setMonth() 12. setYear()

Array Object Methods concat() Sort() Push() Pop()

Math Object Methods round() Max() Min() Pow() Sqrt() Sin(x) Cos(x) Tan(x)

JavaScript Object Model

Form Processing Using JavaScript <html> <head> <title>JavaScript Demo</title> <script type="text/javascript"> function calcSum() { var value1, value2, sum; value1=parseInt(document.myForm.textBox1.value); value2=parseInt(document.myForm.textBox2.value); sum = value1 + value2; document.myForm.textSum.value=sum; } </script> </head>

Form Processing Using JavaScript <body> <form name="myForm"> <input type="text" name="textBox1" /> <br/> <input type="text" name="textBox2" /> <br/> <input type="button" value=“Calculate" onclick="javascript:calcSum()" /> <input type="text" name="textSum"/> </form> </body> </html>

Form Processing Using JavaScript

Program in JavaScript to find out Simple Interest <html> <head> <title>JavaScript Demo</title> <script type="text/javascript"> function calcResult() { var amount, rate, time, result; amount=parseInt(document.myForm.txtAmount.value); rate=parseInt(document.myForm.txtRate.value); time=parseInt(document.myForm.txtTime.value); result = (amount*rate*time)/100; document.myForm.txtResult.value=result; } </script> </head>

Program in JavaScript to find out Simple Interest <body> <form name="myForm"> <input type="text" name="txtAmount" /> <br/> <input type="text" name="txtRate" /> <br/> <input type="text" name="txtTime" /> <br/> <input type="button" value=“Calculate" onclick="javascript:calcResult()" /> <input type="text" name="txtResult"/> </form> </body> </html>