Client-Side Scripting JavaScript.  produced by Netscape for use within HTML Web pages.  built into all the major modern browsers. properties  lightweight,

Slides:



Advertisements
Similar presentations
1 What is JavaScript? JavaScript was designed to add interactivity to HTML pages JavaScript is a scripting language A scripting language is a lightweight.
Advertisements

JavaScript FaaDoOEngineers.com FaaDoOEngineers.com.
The Web Warrior Guide to Web Design Technologies
Computer Science 103 Chapter 4 Advanced JavaScript.
JavaScript 101 Lesson 5: Introduction to Events. Lesson Topics Event driven programming Events and event handlers The onClick event handler for hyperlinks.
Web Development & Design Foundations with XHTML Chapter 14 Key Concepts.
2012 •••••••••••••••••••••••••••••••••• Summer WorkShop Mostafa Badr
Introduction to JavaScript. Aim To enable you to write you first JavaScript.
Copyright © Terry Felke-Morris WEB DEVELOPMENT & DESIGN FOUNDATIONS WITH HTML5 Chapter 14 Key Concepts 1 Copyright © Terry Felke-Morris.
JS: DOM Form Form Object Form Object –The Form object represents an HTML form. –For each instance of a tag in an HTML document, a Form object is created.
CNIT 133 Interactive Web Pags – JavaScript and AJAX Event and Event Handling.
Introduction to JavaScript. JavaScript Facts A scripting language - not compiled but interpreted line by line at run-time. Platform independent. It is.
Chapter 5 Java Script And Forms JavaScript, Third Edition.
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.
Bridges To Computing General Information: This document was created for use in the "Bridges to Computing" project of Brooklyn College. You are invited.
WEEK 3 AND 4 USING CLIENT-SIDE SCRIPTS TO ENHANCE WEB APPLICATIONS.
CNIT 133 Interactive Web Pags – JavaScript and AJAX JavaScript Environment.
JavaScript Part 1.
Copyright © Terry Felke-Morris WEB DEVELOPMENT & DESIGN FOUNDATIONS WITH HTML5 Chapter 14 Key Concepts 1 Copyright © Terry Felke-Morris.
Intro to JavaScript. Use the tag to tell the browser you are writing JavaScript.
CSS Class 7 Add JavaScript to your page Add event handlers Validate a form Open a new window Hide and show elements Swap images Debug JavaScript.
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.
Introduction to JavaScript Basharat Mahmood, Department of Computer Science, CIIT, Islamabad, Pakistan. 1.
Using Client-Side Scripts to Enhance Web Applications 1.
CO1552 Web Application Development HTML Forms, Events and an introduction to JavaScript.
JavaScript - A Web Script Language Fred Durao
JavaScript, jQuery, and Mashups Incorporating JavaScript, jQuery, and other Mashups into existing pages.
JavaScript Adding active content to websites. Goals Understand structure of JavaScript Understand rules of coding Add active content to WebPages Add functions.
Intro to JavaScript. Some simple examples Examples from our webpage Examples from Andrews webpage Today’s Example.
HTML Form Widgets. Review: HTML Forms HTML forms are used to create web pages that accept user input Forms allow the user to communicate information back.
1 JavaScript
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.
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.
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.
ECA 225 Applied Interactive Programming ECA 225 Applied Online Programming control structures, events, objects.
IS2802 Introduction to Multimedia Applications for Business Lecture 3: JavaScript and Functions Rob Gleasure
1 CSC160 Chapter 7: Events and Event Handlers. 2 Outline Event and event handlers onClick event handler onMouseOver event handler onMouseOut event handler.
Making dynamic pages with javascript Lecture 1. Java script java versus javascript Javascript is a scripting language that will allow you to add real.
JavaScript Defined DOM (Document Object Model) General Syntax Body vs. Head Variables Math & Logic Selection Functions & Events Loops Animation Getting.
Pertemuan 5 IT133 Pengembangan Web JavaScript. What is JavaScript? JavaScript was designed to add interactivity to HTML pages JavaScript is a scripting.
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.
LESSON : EVENTS AND FORM VALIDATION -JAVASCRIPT. EVENTS CLICK.
Chapter 5: Intro to Scripting CIS 275—Web Application Development for Business I.
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 and Ajax (JavaScript Environment) Week 6 Web site:
JavaScript Events. Understanding Events Events add interactivity between the web page and the user Events add interactivity between the web page and the.
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.
Javascript Javascript The JavaScript Programming Language – Scripting Languages Executed by an interpreter contained within.
CHAPTER 10 JAVA SCRIPT.
Web Development & Design Foundations with HTML5
Section 17.1 Section 17.2 Add an audio file using HTML
Web Development & Design Foundations with HTML5 7th Edition
JavaScript Defined General Syntax Body vs. Head Variables Math & Logic
Functions, Regular expressions and Events
CS105 Introduction to Computer Concepts
Web Design and Development
Tutorial 10: Programming with javascript
Web Programming– UFCFB Lecture 13
JavaScript and Ajax (JavaScript Events)
Web Programming and Design
CS105 Introduction to Computer Concepts JavaScript
Presentation transcript:

Client-Side Scripting JavaScript

 produced by Netscape for use within HTML Web pages.  built into all the major modern browsers. properties  lightweight, interpreted programming language  Integrated with HTML  Cross-platform

Usage  To improve the design  To validate forms  Detect browsers  Create cookies

Syntax /* Scripts will be written here

Where to use JavaScript

In the Syntax: JS in head body goes here

In the Syntax: JS in body // scripts here

Along with html elements  Syntax: JS along html element Button Clicked

Linking to external JS Syntax : External JS Demo

JavaScript cont..  Alerting a user  Confirming user’s choice  Prompting a users

Alert  Used to interact with a user by popping up an alert box.  It has an “OK” button by default.  The user should click on the ok button or close the alert box before proceeding.

How alerts work Alert box alert(‘Please click ok to continue’);

Confirm Box  To get information back from the user.  Has got “yes” and “no” options.

How confirmation works Confirmation Box confirm(‘can I close this window?’);

Prompt Box  To accept an input from a user.  Has “ok” and “cancel” buttons

How prompt works Prompt Box prompt(‘what is your name:’, ’enter your name’);

JavaScript cont…  Declaring and using variables  Decisions, loops and functions  Events  Page redirection  Form validation

variables  Can hold any type of data  You can start by storing text and then change to storing numbers without JavaScript having any problems.

How variables work Syntax  Using the keyword var var x; x = 10; alert(x);

Decisions  if  if … else  if … else if … else  switch

if Syntax if (condition) { //executable code; }

if … else Syntax if (condition) { //something here } else { //some other thing }

if … else Syntax if (condition) { //something here } else if (condition) { //some other thing } else { //if both the conditions above are not true execute this }

How they works var x = 5; if (x == 2) { alert(x); } else if(x >5) { alert(‘its five’); } else if(x == 5) { document.write(‘the value of x is: ’ + x); } else { document.write(“no value found”); }

switch Has four (4) statements  Test statement  Case statement  Break statement  Default statement

Switch cont… Syntax switch(test) { case ‘1’: //some code here; break; case ‘2’: // some code here; break; default: //default code }

How switch works var x = “honey”; switch(x) { case “boy”: alert(x); break; case “honey”: alert(“hello ” + x); break; default: alert(“you are not ” + x); }

Loops  Used to iterate while a condition is true  If number of iteration is known use for loop  Otherwise use while loop  To run the code at least one use do…while loop

Loops cont… Loops  for loop  while loop  do … while loop

for loop for ( n= 1; n<= 3; n++) { document.write(n +“ ”); }

while loop var degCent = 10; while ( degCent != 100) { document.write(degCent + “ ”); degCent += 10; }

do…while loop  execute at least once, regardless of whether the condition in the while statement evaluates to true. var userAge; do { userAge = prompt(“Please enter your age: ”,””) } while (isNaN(userAge) == true);

functions  Something that performs a particular task  invoked by: Event handlers By statements elsewhere in the script.  Designed for reuse.

functions cont… Syntax: function functionName[arg1,arg2…] { statement[s]; } Remember: function is a keyword and arguments are optional.

How it works How to create a function in JavaScript function displayName(x) { x = prompt(“What is your name please?”,”Enter your name”); alert(“Hello” + x); } displayName(x);

Events  Used to interact with users onclick onmouseover onmouseout onLoad onUnload

How onclick works function showDate() { document.write(Date()); } Show Date

How onmouseover works function displayAlert() { alert(“Your mouse is on the paragraph”); } hover your pointer

How onmouseout works function displayAlert() { alert(“please put your mouse over the paragraph”); } hover your pointer

onLoad and onUnload

Page redirection  When you click a URL to reach to a page X but internally you are directed to another page Y that simply happens because of page re- direction.  Why?  Changing your domain name  Search engine already indexed your domain name  Load a specific webpage for a specific browser version

Page redirection cont…  To redirect your site visitors to a new page, you just need to add a line in your head section as follows: window.location="

Form validation  Used to occur at the server, after the client had entered all necessary data and then pressed the Submit button.  Was lengthy process and over burdening server.  Basic validation  Data format validation

Basic Validation  Make sure data was entered into each form field that required it.

How it works

Data format validation  The data that is entered must be checked for correct form and value

How it works

Document Object Model in JavaScript