Chapter 9. An event-driven, object-based programming language that provides various types of functionality to pages. Object based: it is a language that.

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

Tutorial 5 Windows and Frames Section A - Working with Windows.
1 CSC 551: Web Programming Spring 2004 client-side programming with JavaScript  scripts vs. programs  JavaScript vs. JScript vs. VBScript  common tasks.
Session 8 JavaScript/Jscript: Objects Matakuliah: M0114/Web Based Programming Tahun: 2005 Versi: 5.
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.
 2008 Pearson Education, Inc. All rights reserved JavaScript: Introduction to Scripting.
Basics of ASP.NET. 2 © UW Business School, University of Washington 2004 Outline Installing ASP.NET and Web Matrix Data Types Branching Structure Procedures.
HTML Comprehensive Concepts and Techniques Second Edition Project 8 Integrating JavaScript with HTML.
 2008 Pearson Education, Inc. All rights reserved Document Object Model (DOM): Objects and Collections.
CM143 - Web Week 2 Basic HTML. Links and Image Tags.
Tutorial 11 Working with Operators and Expressions
JavaScript Objects Objects – JavaScript is an object-based language Has built-in objects we will use – You can create your own objects We concentrating.
Introduction to scripting
Chapter 12 Creating and Using XML Documents HTML5 AND CSS Seventh Edition.
JavaScript Events and Event Handlers 1 An event is an action that occurs within a Web browser or Web document. An event handler is a statement that tells.
Using Object-Oriented JavaScript CST 200- JavaScript 4 –
Chapter 5 Java Script And Forms JavaScript, Third Edition.
 2008 Pearson Education, Inc. All rights reserved Document Object Model (DOM): Objects and Collections.
Extracting the System Date  Built-in Date() object  Can be manipulated only by creating a new object instance  var variable = new object  var birthDay.
The Document Object Model. Goals Understand how a JavaScript can communicate with the web page in which it “lives.” Understand how to use dot notation.
WEEK 3 AND 4 USING CLIENT-SIDE SCRIPTS TO ENHANCE WEB APPLICATIONS.
Database-Driven Web Sites, Second Edition1 Chapter 3 INTRODUCTION TO CLIENT-SIDE SCRIPTS.
1 CLIENT-SIDE SCRIPTS. Objectives 2 Learn how to reference objects in HTML documents using the HTML DOM and dot syntax Learn how to create client-side.
1 CS 21A Beginning JavaScript Programming Project 1 Integrating JavaScript and HTML Sonny Huang.
The Web Wizard’s Guide To JavaScript Chapter 6 Working with Dates and Times.
The Web Wizard’s Guide To JavaScript Chapter 6 Working with Dates and Times.
Week 9 PHP Cookies and Session Introduction to JavaScript.
Integrating JavaScript and HTML5 HTML5 & CSS 7 th Edition.
Chapter 3: Data Types and Operators JavaScript - Introductory.
Chapter 8 Cookies And Security JavaScript, Third Edition.
JavaScript, Fourth Edition
Writing a JavaScript User-Defined Function  A function is JavaScript code written to perform certain tasks repeatedly  Built-in functions.
Adobe GoLive Edit and FTP your web pages to a web server.
Tutorial 10 Programming with JavaScript
 2008 Pearson Education, Inc. All rights reserved JavaScript: Functions.
Using Client-Side Scripts to Enhance Web Applications 1.
ALBERT WAVERING BOBBY SENG. Week 5: More JavaScript  Quiz  Announcements/questions.
Lecture 9 The Basics of JavaScript Boriana Koleva Room: C54
 2008 Pearson Education, Inc. All rights reserved JavaScript: Objects.
Chapter 5: Windows and Frames
JavaScript Syntax and Semantics. Slide 2 Lecture Overview Core JavaScript Syntax (I will not review every nuance of the language)
Dr. Qusai Abuein1 Internet & WWW How to program Chap.(6) JavaScript:Introduction to Scripting.
Chapter 2: Variables, Functions, Objects, and Events JavaScript - Introductory.
XP Tutorial 8 Adding Interactivity with ActionScript.
Internet & World Wide Web How to Program, 5/e © by Pearson Education, Inc. All Rights Reserved.
Internet & World Wide Web How to Program, 5/e © by Pearson Education, Inc. All Rights Reserved.
JavaScript. JavaScript is the programming language of HTML and the Web. Easy to learn One of the 3 languages of all developers MUST learn: 1. HTML to.
XP Tutorial 2 New Perspectives on JavaScript, Comprehensive1 Working with Operators and Expressions Creating a New Year’s Day Countdown Clock.
HTML Overview Part 5 – JavaScript 1. Scripts 2  Scripts are used to add dynamic content to a web page.  Scripts consist of a list of commands that execute.
Headings are defined with the to tags. defines the largest heading. defines the smallest heading. Note: Browsers automatically add an empty line before.
Lesson 16. Practical Application 1 We can take advantage of JavaScript and the DOM, to set up a form so that the first text box of a form automatically.
Tutorial 11 1 JavaScript Operators and Expressions.
Project 3: Understanding the JavaScript Object Model Essentials for Design JavaScript Level One Michael Brooks.
JavaScript and Ajax (JavaScript Functions) Week 5 Web site:
1 Objects In JavaScript. 2 Types of Object in JavaScript Built-in objects User Defined Objects Browser Object Document Object Model.
JavaScript Tutorial. What is JavaScript JavaScript is the programming language of HTML and the Web Programming makes computers do what you want them to.
Basic Objects. Math Object  Math.cos( x ), x in radians  Math.sqrt ( x )  Math.pow ( x, y )  Math.ceil( x )  etc.
Chapter 6 JavaScript: Introduction to Scripting
“Under the hood”: Angry Birds Maze
Tutorial 10 Programming with JavaScript
Project 9 Creating Pop-up Windows, Adding Scrolling Messages, and Validating Forms.
JavaScript Syntax and Semantics
14 A Brief Look at JavaScript and jQuery.
Objectives Insert a script element Write JavaScript comments
BY: SITI NURBAYA ISMAIL FACULTY of COMPUTER and MATHEMATICAL SCIENCES
WEB PROGRAMMING JavaScript.
JavaScript: Introduction to Scripting
Web Programming and Design
Presentation transcript:

Chapter 9

An event-driven, object-based programming language that provides various types of functionality to pages. Object based: it is a language that uses built-in objects that belong to the browser.

ObjectDescription ArrayReturns an ordered set of values BooleanConverts objects to Boolean values DateAccesses the system time and date DocumentRepresents the content of a browser's window FunctionAccesses information about specific functions HistoryKeeps track of Web pages visited locationSwitches to a new Web page MathPerforms calculations StringRepresents a set of characters WindowRepresents a browser window

attributes that describe an object's characteristics truck.style="pickup“ style=property, pickup = value

actions that an object can perform. truck.load() truck = object, load=method, () = arguement

value given to a method truck.load("firewood") firewood = describes material loaded into truck

Function: code that is written to perform certain tasks repeatedly Placed in the section of the HTML code User defined functions use generic tags to display dynamic information Container: tag that identifies a section of HTML code using the id attribute. Ex:

 Date() object access the current system date and time Can use 3 other methods to build a string for a a current date: getDate(), getMonth(), getFullYear()  Example: var sysDate=new Date() ; var sysDate=new Date(“February 12, 2014”)  new is a required keyword  2 nd example specifies a date for the sysDate variable

 To use the date and time, the variable must be converted to a string toLocaleString() method var variableName=dateString.toLocalString()  Example: Var curDate=sysDate.toLocaleString() curDate contains the date and time stored as Day of the Week Month Date Year HH:MM:SS

 Returns the positions of the first occurrence of a specified value in a string var position=strngValue.indexOf(“x”)  Example: curDate=“February 12, 2014” dateLocate=curDate.indexOf(“,”) Returns the position of the comma found in the string value of curDate: 11

 Uses 2 parameters (x,y) where x is the starting point of the string and y is the location of the last character needed. birthDay.substring(17,20) var variableName=string.substring(x,y)  Example: weekDay=dayofweek.substring(0,dateLocate) The variable weekDay containsf the substring result giving the current day of the week.

 Similar to substring() but differs in how it uses parameter values.  Example: var dayofweek=today.toLocaleString()  Converts date into string yearLocate=dayofweek.indexOf(“2014”) Year=dayofweek.substr(yearLocate,4)  The variable year contains the 4 digit year

 Can be used to store a future date. var variableName = new Date(“September 26, 2043”)

 Use the getTime() method of the Date() object  Returns the number of milliseconds that have elapsed since Jan. 1,  Must subtract the values to find the milliseconds. var variable = time1.getTime() – time2.getTime()

 Part of the Math() object  Used to round to the nearest Integer  To convert milliseconds to days, divide the number of milliseconds stored in the variable by the product of: 1000*60*60*24 var daysToExpo=Math.ceil(daysToGo/(1000*60*60*24))

 Allows dynamic content to be placed in the contained associated with the unique tag id.  Not recognized by Firefox!  Use the concatenate (+) sign to link elements tagId.innerHTML=“text string”+variable+”text string”

 A method of the document object  Form: document.getElementsByTagName(‘html’)  Example: styleObject= document.getElementsByTagName(‘html’)[0].style [0] represents which value you want returned, in an array format.

 Only works in IE!  Properties available: FaceColor, ArrowColor, HighlilghtColor, 3DlightColor, DarkshadowColor, TrackColor, and ShadowColor  Ex: styleObject.scrollbarFaceColor=“#ffde5b”

 Used with dropdown boxes  User selects an item in the list and the selectedIndex property returns the value of the item.  Items are “numbered” starting with 0.  Form: var Name=formName.SelectListName.selectedIndex

 Used to tell the browser where the new pages are located (linked in dropdown).  Form: object=window.location or window.location = URL Object = variable or other object that can display the URL URL = the address of the page to display

 lastModified Property displays the dte in the form of mm/dd/yyyy hh:mm:ss  Form: document.lastModified lastModified = property of the document object Ex: var lastModified = document.lastModified Could use: var lastModified =lastModified.substring(0,10) to only get date, not time.