Chapter 4 Java Script - Part1. 2 Outlines Introduction to Java Script Variables, Operators and Functions Conditional statements JavaScript Objects Forms.

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

Chapter 08: Adding Adding Interactivity Interactivity With With Behaviors Behaviors By Bill Bennett Associate Professor MSJC CIS MVC.
 2001 Prentice Hall, Inc. All rights reserved. 1 Chapter 7 - JavaScript: Introduction to Scripting Outline 7.1 Introduction 7.2 Simple Program: Printing.
JavaScript (Part 2) CS 183 4/13/2010. JavaScript (Part 2) Will cover: ◦ For.. In ◦ Events ◦ Try.. Catch, Throw ◦ Objects.
Chapter 7 © 2001 by Addison Wesley Longman, Inc. 1 Chapter 7 Sebesta: Programming the World Wide Web.
1 Outline 13.1Introduction 13.2A Simple Program: Printing a Line of Text in a Web Page 13.3Another JavaScript Program: Adding Integers 13.4Memory Concepts.
Javascript Document Object Model. How to use JavaScript  JavaScript can be embedded into your html pages in a couple of ways  in elements in both and.
JavaScript Bartosz Sakowicz. JavaScript - basics JavaScript is used in millions of Web pages to improve the design, validate forms, detect browsers, create.
Information Technology Center Hany Abdelwahab Computer Specialist.
JavaScript Client Side scripting. Client-side Scripts Client-side scripts, which run on the user’s workstation can be used to: Validate user inputs entered.
Introduction to JavaScript. Aim To enable you to write you first JavaScript.
Introduction to scripting
4.1 JavaScript Introduction
Introduction to JavaScript. JavaScript Facts A scripting language - not compiled but interpreted line by line at run-time. Platform independent. It is.
JavaScript Defined DOM (Document Object Model) General Syntax Body vs. Head Variables Math & Logic Selection Functions & Events Loops Animation Getting.
Event Handlers CS101 Introduction to Computing. Learning Goals Learn about event handlers Determine how events are useful in JavaScript Discover where.
Generations of Programming Languages First generation  Machine Language Second Generation  Assembly Language Third Generation  Procedural language such.
JavaScript II ECT 270 Robin Burke. Outline JavaScript review Processing Syntax Events and event handling Form validation.
CNIT 133 Interactive Web Pags – JavaScript and AJAX JavaScript Environment.
JavaScript Part 1.
Internet Mark-up Languages CO32036 Part Lecture: Elementary JavaScript.
JavaScript Informatics for economists I. Introduction Programming language used in web pages. Simple and easy to use – written in HTML document. Client.
DHTML: Dynamic HTML Internet Technology1. What is DHTML? A collection of enhancements to HTML ► To create dynamic and interactive websites Combination.
INTRODUCTION TO JAVASCRIPT AND DOM Internet Engineering Spring 2012.
Introduction to JavaScript Basharat Mahmood, Department of Computer Science, CIIT, Islamabad, Pakistan. 1.
An Introduction to JavaScript Summarized from Chapter 6 of “Web Programming: Building Internet Applications”, 3 rd Edition.
 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,
Introduction to Javascript. What HTML Can & Can Not Do HTML Can HTML Can Display text Display text Display images Display images Display even animated.
Intro to JavaScript Scripting language –ECMAScript compliant –Client side vs. server side Syntactic rules –White space –Statement end: ; optional –Comments:
JavaScript, jQuery, and Mashups Incorporating JavaScript, jQuery, and other Mashups into existing pages.
Intro to JavaScript. Some simple examples Examples from our webpage Examples from Andrews webpage Today’s Example.
Input & Output Functions JavaScript is special from other languages because it can accept input and produce output on the basis of that input in the same.
JavaScript - Basic Concepts Prepared and Presented by Hienvinh Nguyen, Afshin Tiraie.
44238: Dynamic Web-site Development Client Side Programming Ian Perry Room:C48 Extension:7287
1 JavaScript 2 JavaScript. 2 Rollovers Most web page developers first use JavaScript for rollovers A rollover is a change in the appearance of an element.
Scott Marino MSMIS Summer Session Web Site Design and Authoring Session 8 Scott Marino.
Chapter 14: Dynamic HTML: Event Model Presented by: Colbie Brown CS340 Java Web Development Dr. Gloria Carter Love.
JavaScript Making Web pages come alive. Objectives Be able to read JavaScript scripts Be able to write JavaScript scripts.
Event JavaScript's interaction with HTML is handled through events that occur when the user or browser manipulates a page. When the page loads, that is.
 2000 Deitel & Associates, Inc. All rights reserved. Outline 8.1Introduction 8.2A Simple Program: Printing a Line of Text in a Web Page 8.3Another JavaScript.
CSS1 Dynamic HTML Objects, Collections & Events. CSS2 Introduction Dynamic HTML treats HTML elements as objects. Element’s parameters can be treated as.
JavaScript Introduction.  JavaScript is a scripting language  A scripting language is a lightweight programming language  A JavaScript can be inserted.
Introduction To JavaScript. Putting it Together (page 11) All javascript must go in-between the script tags. All javascript must go in-between the script.
1 Chapter 3 – JavaScript Outline Introduction Flowcharts Control Structures if Selection Structure if/else Selection Structure while Repetition Structure.
Jaana Holvikivi 1 Introduction to Javascript Jaana Holvikivi Metropolia.
1 CSC160 Chapter 7: Events and Event Handlers. 2 Outline Event and event handlers onClick event handler onMouseOver event handler onMouseOut event handler.
© 2007 D. J. ForemanJS-1 A Light Introduction for Non-programmers JavaScript for Beginners.
JavaScript Defined DOM (Document Object Model) General Syntax Body vs. Head Variables Math & Logic Selection Functions & Events Loops Animation Getting.
Web Programming Java Script & jQuery Web Programming.
CIS 3.5 Lecture 2.3 "Introduction to JavaScript".
Copyright © Terry Felke-Morris WEB DEVELOPMENT & DESIGN FOUNDATIONS WITH HTML5 7 TH EDITION Chapter 14 Key Concepts 1 Copyright © Terry Felke-Morris.
Chapter 7 - JavaScript: Introduction to Scripting Outline 7.1 Introduction 7.2 Simple Program: Printing a Line of Text in a Web Page 7.3 Another JavaScript.
5 th and 4 th ed: some from chapters 9, 12, 13 SY306 Web and Databases for Cyber Operations Slide Set #8: Dynamic HTML.
JavaScript II ECT 270 Robin Burke. Outline Functions Events and event handling Form validation.
JavaScript Event Handlers. Introduction An event handler executes a segment of a code based on certain events occurring within the application, such as.
Chapter 5: Intro to Scripting CIS 275—Web Application Development for Business I.
JavaScript and Ajax (JavaScript Environment) Week 6 Web site:
Web Programming Java Script-Introduction. What is Javascript? JavaScript is a scripting language using for the Web. JavaScript is a programming language.
WEB SYSTEMS & TECHNOLOGY. Java Script  JavaScript created by Netscape  It is also client side programming  It can be use for client side checks.
 2001 Prentice Hall, Inc. All rights reserved. Outline 1 JavaScript.
JavaScript is a programming language designed for Web pages.
Barb Ericson Georgia Institute of Technology May 2006
Web Development & Design Foundations with HTML5 7th Edition
JavaScript for Beginners
DHTML Javascript Internet Technology.
DHTML Javascript Internet Technology.
JavaScript Defined General Syntax Body vs. Head Variables Math & Logic
Introduction to JavaScript
JavaScript for Beginners
Presentation transcript:

Chapter 4 Java Script - Part1

2 Outlines Introduction to Java Script Variables, Operators and Functions Conditional statements JavaScript Objects Forms Validation

3 Introduction to Java Script It is a scripting language. Used for client side validations Decreasing the network traffic. Increasing the functionality of web server Java script is embedded into HTML It is an interpreter language No Data Types – Loosely typed language – Declare variables any where. Event driven language

4 Generating HTML Dynamically Idea Script is interpreted when the page is loaded, and uses document.write or document.writeln to insert HTML at the location the script occurs Template... Regular HTML <!-- Build HTML Here // --> More Regular HTML

5 A Simple Script See Program 1 First JavaScript Page First JavaScript Page window.document.write(" "); window.document.write("Hello World Wide Web"); window.document.write(" ");

6 Simple Script, Result

7 Variables in JavaScript See Program 2 Variables in JavaScript To print 1 to 10 numbers in JavaScript for(var i=1;i<=10;i++) { window.document.write(i); window.document.write(" "); } A Simple Script to print Numbers

8 Variables in JavaScript To print a string 10 times in JavaScript for(var i=1;i Hello World "); window.document.write(" "); } A Simple Script to print String See Program 3

9 Functions in JavaScript See Program 4 Functions JavaScript function display() { window.document.write(" Hello World "); } display();

10 Functions JavaScript function display(str) { window.document.write(" "+str+" "); } display("Hello"); Passing string to a function See Program 5

11 Calling function from one file to another See Program 6 Functions JavaScript display("Imam Muhammed Ibn Saud Islamic Uiversity"); function display(str) { window.document.write(" "+str+" ") ; }

12 Events In JavaScript onLoad onUnload onClick onMouseOver onMouseOut onFocus onBlur onSelect onSubmit etc…

Example Simple JavaScript Button <!-- function dontClick() { alert("I told you not to click!"); } // --> Simple JavaScript Button <INPUT TYPE="BUTTON" VALUE="Don't Click Me" onClick="dontClick()">

Result

15 Object Hierarchy

16 Window Object Every object has properties and methods Every object has properties and methods Using a special loop called for in is used to display properties of window object Using a special loop called for in is used to display properties of window object Properties – See Program 7 Properties – See Program 7 Methods – open(), close(), focus(), blur(), moveBy(), moveTo(), resizeBy(), resizeTo() etc… Methods – open(), close(), focus(), blur(), moveBy(), moveTo(), resizeBy(), resizeTo() etc…

17 Program 7.html Functions JavaScript for (var i in window) { window.document.write(i+"="+window[i]+" "); }

18 7.html, Result

Window Object

20 Example for window methods Some more methods of window are alert(), prompt(), confirm() Program 8.html

21 See Program 9 Example for onclick writes the text in new document - See Program 9 function dis() { var w=window.open() w.document.write("hello world"+" ") }

22 Program 9 - Result

23 See Program 10 Example using confirm() and alert() See Program 10 function dis() { var ch=window.confirm("open a window"); if (ch) { window.open(); } else { alert("Dont open a window"); }

24 Example 10 - Result

E.g.Dynamic Welcome Page Using Prompt and Alert Boxes <!-- var name; // string entered by the user // read the name from the prompt box as a string name = window.prompt( "Please enter your name", "GalAnt" ); document.writeln( " Hello " + name + ", welcome to JavaScript programming! " ); // --> Click Refresh (or Reload) to run this script again.

Result