Internet Mark-up Languages CO32036 Part Lecture: Elementary JavaScript.

Slides:



Advertisements
Similar presentations
Chapter 08: Adding Adding Interactivity Interactivity With With Behaviors Behaviors By Bill Bennett Associate Professor MSJC CIS MVC.
Advertisements

JavaScript FaaDoOEngineers.com FaaDoOEngineers.com.
JavaScript and the DOM Les Carr COMP3001 Les Carr COMP3001.
Introduction to JavaScript Module 1 Client Side JS Programming M-GO Sponsored By
The Web Warrior Guide to Web Design Technologies
Georgia Institute of Technology JavaScript part 2 Barb Ericson Georgia Institute of Technology May 2006.
Chapter 7 © 2001 by Addison Wesley Longman, Inc. 1 Chapter 7 Sebesta: Programming the World Wide Web.
CS 299 – Web Programming and Design Overview of JavaScript and DOM Instructor: Dr. Fang (Daisy) Tang.
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 What JavaScript Is: a general purpose scripting language that allows a static page to interact with users and respond to events.
Introduction to JavaScript. Aim To enable you to write you first JavaScript.
UNIT 6 JAVASCRIPT EVENT HANDLERS &WEB BROWSERS DETECTION.
Javascript and the Web Whys and Hows of Javascript.
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.
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.
Chapter 19: Adding JavaScript
Bridges To Computing General Information: This document was created for use in the "Bridges to Computing" project of Brooklyn College. You are invited.
CNIT 133 Interactive Web Pags – JavaScript and AJAX JavaScript Environment.
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.
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.
Client Scripting1 Internet Systems Design. Client Scripting2 n “A scripting language is a programming language that is used to manipulate, customize,
Lesson13. JavaScript JavaScript is an interpreted language, designed to function within a web browser. It can also be used on the server.
INTRODUCTION TO JAVASCRIPT AND DOM Internet Engineering Spring 2012.
Introduction to JavaScript Basharat Mahmood, Department of Computer Science, CIIT, Islamabad, Pakistan. 1.
Client-Side Scripting JavaScript.  produced by Netscape for use within HTML Web pages.  built into all the major modern browsers. properties  lightweight,
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.
Lecture 10 JavaScript: DOM and Dynamic HTML Boriana Koleva Room: C54
44238: Dynamic Web-site Development Client Side Programming Ian Perry Room:C48 Extension:7287
ECA 225 Applied Interactive Programming1 ECA 225 Applied Online Programming basics.
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.
CSC318 – DYNAMIC WEB APPLICATION DEVELOPMENT BY: SITI NURBAYA ISMAIL FACULTY of COMPUTER and MATHEMATICAL SCIENCES.
By Tharith Sriv. To write a web page you use: HHTML (HyperText Markup Language), AASP (Active Server Page), PPHP (HyperText Preprocessor), JJavaScript,
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.
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.
Making dynamic pages with javascript Lecture 1. Java script java versus javascript Javascript is a scripting language that will allow you to add real.
Project 8: Reacting to Events Essentials for Design JavaScript Level One Michael Brooks.
COS 125 DAY 20. Agenda Assignment 8 not corrected yet Assignment 9 posted  Due April 16 New course time line Discussion on Scripts 
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".
7. JavaScript Events. 2 Motto: Do you think I can listen all day to such stuff? –Lewis Carroll.
Web Programming Overview. Introduction HTML is limited - it cannot manipulate data How Web pages are extended (include): –Java: an object-oriented programming.
JavaScript Events.
JavaScript Event Handlers. Introduction An event handler executes a segment of a code based on certain events occurring within the application, such as.
LESSON : EVENTS AND FORM VALIDATION -JAVASCRIPT. EVENTS CLICK.
Chapter 4 Java Script - Part1. 2 Outlines Introduction to Java Script Variables, Operators and Functions Conditional statements JavaScript Objects Forms.
1 CSC160 Chapter 1: Introduction to JavaScript Chapter 2: Placing JavaScript in an HTML File.
JavaScript and Ajax (JavaScript Environment) Week 6 Web site:
Functions Wouldn’t it be nice to be able to bring up a new animal and paragraph without having to reload the page each time? We can! We can place the.
SE-2840 Dr. Mark L. Hornick 1 Dynamic HTML Handling events from DOM objects.
Java Script Introduction. Java Script Introduction.
Week 3: Introduction to Javascript
Week 4: Introduction to Javascript
CIIT-Human Computer Interaction-CSC456-Fall-2015-Mr
Web Development & Design Foundations with HTML5 7th Edition
4. Javascript Pemrograman Web I Program Studi Teknik Informatika
JavaScript Events.
DHTML Javascript Internet Technology.
DHTML Javascript Internet Technology.
JavaScript Defined General Syntax Body vs. Head Variables Math & Logic
Tutorial 10: Programming with javascript
JavaScript and Ajax (JavaScript Events)
CNIT 133 Interactive Web Pags – JavaScript and AJAX
Introduction to JavaScript
Week 5: Recap and Portfolio Site
Barb Ericson Georgia Institute of Technology May 2006
Presentation transcript:

Internet Mark-up Languages CO32036 Part Lecture: Elementary JavaScript

Lecture Contents Description Applications Location within document Time of execution Variables Statements Case sensitivity Scope of Variables Programming structures Events Strings Comments What next?

What is JavaScript? Scripting language = Written in text form and interpreted line by line Non-copyright – anyone can use it Designed to make web pages interactive JavaScript ≠ Java. Name chosen only to make it sound cool and groovy Microsoft have Jscript, which is non- standard. Causes solvable problems

JavaScript can: Calculate (eg currency converters) Change contents of pages –As they are loaded –After they are loaded Respond to client actions Read, write and check contents of forms Detect which browser is being used Deposit cookies

1/3 places to put JavaScript:

2/3 places to put JavaScript: function popup(){ alert(‘Boo!’);} <input type='button' onclick=“javascript:popup()” value='wash'/>

3/3 places to put JavaScript: <input type='button' onclick=“javascript:popup()” value='wash'/>

3/3 places to put JavaScript: The contents of popup.js: function popup(){ alert(‘Boo!’);}

Script in the body alert(‘Boo!’);

Execution time If script is to execute as the page is loaded, put it in the body If it’s a function to be executed after the page has loaded, put it in the head.

Variables var mystring var mystring = ‘Boo!’ mystring = ‘Boo!’ mystring = ‘Boo!’; A statement may be ended by a semicolon or a line feed. Var and semicolons are optional but JavaScript IS case-sensitive. Variable type is taken as implied

Scope Lifetime of variables is as in any other language: Globals last for the lifetime of the page Variables within functions last for the time the function is functioning Variables within functions can be read by functions within functions (got that?)

If-Then-Else var d = new Date() var time = d.getHours() if (time </body

Case -> Switch switch (myInput) { case 5: document.write(“Five") break case 6: document.write(“Six") break case 0: document.write(“Zero") break default: document.write(“Unexpected!") }

Loops - For var i=0 for (i=0;i ") }

Loops - While var i=0; while (i ") i=i+1 }

Events Run your mouse over this text.

Events Most HTML objects can be given events. These include: onfocus, unblur, onchange (usually form fields) onclick (buttons and link text) onmouseover, onmouseout (swap images for animation) onsubmit (form checking)

Events onload, onunload (ie on opening or closing a page) Used for browser checks, cookie checks and extra windows containing irritating adverts. There is also: OnDblClick, OnKeyDown, OnKeyPress OnKeyUp, OnMouseDown, OnMouseMove, OnMouseUp…

Strings Getting text into JavaScript is not hard: Text may be input from a separate file (see later lectures) Alternatively, it may be constructed in the document

Strings String manipulation is as you would expect: Var strvar=“a custard pie”; document.write(strvar); document.write(“I would like ”+strvar) alert(strvar.length); document.write(strvar.toUpperCase); document.write(" "+strvar+" ")

Comments It does NOT work for JavaScript

Comments

Comments // In JavaScript, double slashes will // comment out a single line /* This is the way of commenting out multiple lines of text (or code when you are debugging */

What Now? This was only an introduction Try the w3schools tutorial on Javascript W3schools also has a reference on all available JavaScript functions Try out examples (from anywhere) using hapedit, W3schools TryIt editor or the IE “view source” facility.

Lecture Review Description Applications Location within document Time of execution Variables Statements Case sensitivity Scope of Variables Programming structures Events Strings Comments What next?

Final Word If you’re stuck, get a good book. My own is the Peachpit Press one. You don’t need a server to try out JavaScript – only a browser. It will run from your desktop. Enjoy!!