Sue Wills July 2009. Objects The JavaScript language is completely centered around objects, and because of this, it is known as an Object Oriented Programming.

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.
JavaScript FaaDoOEngineers.com FaaDoOEngineers.com.
Lesson 12- Unit L Programming Web Pages with JavaScript.
The Web Warrior Guide to Web Design Technologies
20-Jun-15 JavaScript and HTML Simple Event Handling.
Information Technology Center Hany Abdelwahab Computer Specialist.
JavaScript 101 Lesson 5: Introduction to Events. Lesson Topics Event driven programming Events and event handlers The onClick event handler for hyperlinks.
DHTML. What is DHTML?  DHTML is the combination of several built-in browser features in fourth generation browsers that enable a web page to be more.
4.1 JavaScript Introduction
JavaScript, Fifth Edition Chapter 1 Introduction to JavaScript.
JavaScript Defined DOM (Document Object Model) General Syntax Body vs. Head Variables Math & Logic Selection Functions & Events Loops Animation Getting.
Created by, Author Name, School Name—State FLUENCY WITH INFORMATION TECNOLOGY Skills, Concepts, and Capabilities.
CNIT 133 Interactive Web Pags – JavaScript and AJAX JavaScript Environment.
Lecture 11 – DOM Scripting SFDV3011 – Advanced Web Development Reference: 1.
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,
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.
INTRODUCTION TO JAVASCRIPT AND DOM Internet Engineering Spring 2012.
1 JavaScript in Context. Server-Side Programming.
TUTORIAL 10: PROGRAMMING WITH JAVASCRIPT Session 2: What is JavaScript?
Extending HTML CPSC 120 Principles of Computer Science April 9, 2012.
DHTML AND JAVASCRIPT Genetic Computer School LESSON 5 INTRODUCTION JAVASCRIPT G H E F.
Chapter 5: Windows and Frames
JavaScript - A Web Script Language Fred Durao
Web Development 101 Presented by John Valance
XP Tutorial 8 Adding Interactivity with ActionScript.
Internet & World Wide Web How to Program, 5/e © by Pearson Education, Inc. All Rights Reserved.
4 HTML Basics Section 4.1 Format HTML tags Identify HTML guidelines Section 4.2 Organize Web site files and folder Use a text editor Use HTML tags and.
4. Javascript M. Udin Harun Al Rasyid, S.Kom, Ph.D Lab Jaringan Komputer (C-307) Desain.
1 Server versus Client-Side Programming Server-SideClient-Side.
1 JavaScript in Context. Server-Side Programming.
WDMD 170 – UW Stevens Point 1 WDMD 170 Internet Languages eLesson: Variables, Functions and Events (NON-Audio version) © Dr. David C. Gibbs WDMD.
CO1552 – Web Application Development Further JavaScript: Part 1: The Document Object Model Part 2: Functions and Events.
HTML Basics. HTML Coding HTML Hypertext markup language The code used to create web pages.
JavaScript Defined DOM (Document Object Model) General Syntax Body vs. Head Variables Math & Logic Selection Functions & Events Loops Animation Getting.
Java Script About Java Script Document Object Model Incorporating JavaScript Adding JavaScript to HTML Embedding a Javascript External Scripts Javascript.
Introduction to JavaScript CSc 2320 Fall 2014 Disclaimer: All words, pictures are adopted from “Simple JavaScript”by Kevin Yank and Cameron Adams and also.
Tutorial 10 Programming with JavaScript. 2New Perspectives on HTML, XHTML, and XML, Comprehensive, 3rd Edition Objectives Learn the history of JavaScript.
JavaScript. JavaScript Introduction JavaScript is the world's most popular programming language. It is the language for HTML and the web, for servers,
Tutorial 10 Programming with JavaScript. 2New Perspectives on HTML, XHTML, and XML, Comprehensive, 3rd Edition Objectives Learn the history of JavaScript.
Introduction to JavaScript MIS 3502, Spring 2016 Jeremy Shafer Department of MIS Fox School of Business Temple University 2/2/2016.
1 Lesson 6 Introducing JavaScript HTML and JavaScript BASICS, 4 th Edition.
Javascript Basic Concepts Presentation By: Er. Sunny Chanday Lecturer CSE/IT RBIENT.
CGS 3066: Web Programming and Design Spring 2016 Introduction to JavaScript.
JavaScript and Ajax (JavaScript Environment) Week 6 Web site:
XML DOM Week 11 Web site:
JavaScript: A short introduction Joseph Lee Created by Joseph Lee.
PHP using MySQL Database for Web Development (part II)
Introduction to.
DHTML.
Programming Web Pages with JavaScript
Unit M Programming Web Pages with
Chapter 6 JavaScript: Introduction to Scripting
Tutorial 10 Programming with JavaScript
JavaScript is a programming language designed for Web pages.
Unit M Programming Web Pages with
4. Javascript Pemrograman Web I Program Studi Teknik Informatika
PHP Introduction.
14 A Brief Look at JavaScript and jQuery.
JavaScript an introduction.
Web Systems Development (CSC-215)
Objectives Insert a script element Write JavaScript comments
DHTML Javascript Internet Technology.
DHTML Javascript Internet Technology.
PHP.
Tutorial 10 Programming with JavaScript
Tutorial 10: Programming with javascript
JavaScript Basics What is JavaScript?
JavaScript is a scripting language designed for Web pages by Netscape.
Presentation transcript:

Sue Wills July 2009

Objects The JavaScript language is completely centered around objects, and because of this, it is known as an Object Oriented Programming Language.

What is an object? An object is a thing. For example a number is an object. An array is an object. Your browser window is an object. A form in your document is an object. There are lots more, and you can create your own objects in JavaScript.

JavaScript object In the context of a web page, a JavaScript object is any scriptable HTML element - that is any HTML element within a document that may be accessed through the JavaScript language. Scriptable HTML elements are associated with the Document Object Model, also known as the DOM. The browser window is not an HTML element, but it is a scriptable object.

Objects Objects can contain objects. For example, your document can have a form in it. This form is a 'child object' of the document. Therefore the document is the 'parent object' of the form. To reference the child object, we have to go through the parent object, eg. document.myForm

Document Object Model The Document Object Model defines the logical structure of documents and the way a document is accessed and manipulated. Document Object Model allows programmers to build documents, navigate their structure, and add, modify, or delete elements and content. Elements in an HTML or XML document can be accessed, changed, deleted, or added using the Document Object Model, with a few exceptions (in xml) JavaScript can completely rewrite a page.

W3C DOM Specification The objective for the Document Object Model is to provide a standard programming interface that can be used in a wide variety of environments and applications. The DOM is designed to be used with any programming language.

Object Properties Objects have properties, which you can think of as characteristics of an object. Eg href (url string in the browser that determines the page your browser loads) bgColor (background color of the document) value (the text - or lack thereof - in a form text field) src (path and filename of an image)

Object methods Methods are actions that can be applied directly to objects. alert() causes an alert dialog box to appear over the page that launched it (window). write() writes content to a page (document). focus() causes the mouse cursor to be inserted into a form element (text field on form).

Dot syntax Remember that with JavaScript has to do with objects. Even the JavaScript syntax has to do with objects. To access an object, property, or method, its reference must include every object that contains it, separated by a dot. This is called the "dot syntax".

Hierarchy The complete path to an object must be included in a reference to a JavaScript object. This path is referred to as the "containment hierarchy". With HTML the path to a file uses slashes. With JavaScript objects, properties and methods you use "dots" or periods. eg document.formName.textFieldName.value

Methods And The Dot Syntax Methods are also physically attached to their objects via the dot syntax. To use a method of an object you must first include the complete path to the object (separated by dots of course) the a dot prior to the method. Eg document.formName.TextFieldName.focus() focus() is a method

Referring To Objects HTML Names Eg So the JavaScript will look like this: document.frog.legs.focus()

JavaScript Variables JavaScript variables are used to hold values or expressions. A variable can have a short name, like x, or a more descriptive name, like carname. Rules for JavaScript variable names: Variable names are case sensitive (y and Y are two different variables) Variable names must begin with a letter or the underscore character Note: Because JavaScript is case-sensitive, variable names are case-sensitive.

JavaScript data types Integers Floating point - Examples are 3.14, -3.14, 314e-2 Boolean values (true or false). String values - May be enclosed by single ' or double " quotes. The \' or \"sequence of characters will insert a quote character into a string. Arrays of any of the above types. Objects.

Functions A function contains code that will be executed by an event or by a call to the function. You may call a function from anywhere within a page (or even from other pages if the function is embedded in an external.js file). Functions can be defined both in the and in the section of a document. However, to assure that a function is read/loaded by the browser before it is called, it could be wise to put functions in the section.

End