Copyright ©2005  Department of Computer & Information Science Beginning DHTML: Working with Browser Objects.

Slides:



Advertisements
Similar presentations
Copyright ©2005 Department of Computer & Information Science Advanced DHTML & DOM: Working with the Window Object.
Advertisements

JavaScript FaaDoOEngineers.com FaaDoOEngineers.com.
The Web Warrior Guide to Web Design Technologies
Tutorial 16 Working with Dynamic Content and Styles.
Chapter 16 Dynamic HTML and Animation The Web Warrior Guide to Web Design Technologies.
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.
 2008 Pearson Education, Inc. All rights reserved Document Object Model (DOM): Objects and Collections.
JavaScript 101 Lesson 5: Introduction to Events. Lesson Topics Event driven programming Events and event handlers The onClick event handler for hyperlinks.
Tutorial 11 Working with Operators and Expressions
The Browser Object Model (BOM) The API of JavaScript’s browser host environment SE-2840 Dr. Mark L. Hornick 1.
JavaScript, Third Edition
Chapter 9 Introduction to the Document Object Model (DOM) JavaScript, Third Edition.
DHTML - Introduction Introduction to DHTML, the DOM, JS review.
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.
Server vs Client-side validation. JavaScript JavaScript is an object-based language. JavaScript is based on manipulating objects by modifying an object’s.
 2008 Pearson Education, Inc. All rights reserved Document Object Model (DOM): Objects and Collections.
Ku-Yaw Chang Assistant Professor, Department of Computer Science and Information Engineering Da-Yeh University.
WEEK 3 AND 4 USING CLIENT-SIDE SCRIPTS TO ENHANCE WEB APPLICATIONS.
IT – som værktøj Bent Thomsen Institut for Datalogi Aalborg Universitet.
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.
Lesson 19. JavaScript errors Since JavaScript is an interpreted language, syntax errors will usually cause the script to fail. Both browsers will provide.
UFCEWT-20-3 Advanced Topics in Web Development Lecture 4 : JavaScript, Browsers & the HTML DOM-API.
History, Navigator, Screen and Form Objects Basharat Mahmood, Department of Computer Science, CIIT, Islamabad, Pakistan 1.
The Web Wizard’s Guide To JavaScript Chapter 6 Working with Dates and Times.
Integrating JavaScript and HTML5 HTML5 & CSS 7 th Edition.
Working with background, images and date object Basharat Mahmood, Department of Computer Science, CIIT, Islamabad, Pakistan 1.
Creating an Animated Web Page
Working with Objects Creating a Dynamic Web Page.
CITS1231 Web Technologies JavaScript and Document Object Model.
XP Tutorial 4 New Perspectives on JavaScript, Comprehensive1 Working with Objects Creating an Animated Web Page.
ASP.NET.. ASP.NET Environment ASP.NET is Microsoft's programming framework that enables the development of Web applications and services. It is an easy.
Lesson13. JavaScript JavaScript is an interpreted language, designed to function within a web browser. It can also be used on the server.
JavaScript, Fourth Edition
INTRODUCTION TO JAVASCRIPT AND DOM Internet Engineering Spring 2012.
WebVizOr: A Fault Detection Visualization Tool for Web Applications Goal: Illustrate and evaluate the uses of WebVizOr, a new tool to aid web application.
Extending HTML CPSC 120 Principles of Computer Science April 9, 2012.
Introduction to JavaScript 41 Introduction to Programming the WWW I CMSC Winter 2004 Lecture 17.
DHTML - Introduction Chapter Introduction to DHTML, the DOM, JS review.
 2001 Deitel & Associates, Inc. All rights reserved. 1 Chapter 20 – Dynamic HTML: Object Model and Collections Outline 20.1Introduction 20.2Object Referencing.
DHTML: Working with Objects Creating a Dynamic Web Page.
Tutorial 5 Windows and Frames Section B - Working with Frames and Other Objects Go to Other Objects.
Chapter 5: Windows and Frames
XP Tutorial 6 New Perspectives on JavaScript, Comprehensive1 Working with Windows and Frames Enhancing a Web Site with Interactive Windows.
Copyright ©2005  Department of Computer & Information Science Introducing Dialogue Windows.
Chapter 7: DHTML: Object Model and Collections CIS 275—Web Application Development for Business I.
 2004 Prentice Hall, Inc. All rights reserved. Chapter 13 - Dynamic HTML: Object Model and Collections Outline 13.1 Introduction 13.2 Object Referencing.
Internet & World Wide Web How to Program, 5/e. © by Pearson Education, Inc. All Rights Reserved.2 Revised by Dr. T. Tran for CSI3140.
Introduction to JavaScript Objects, Properties, Methods.
Project 10: Exploring the Window Object Essentials for Design JavaScript Level One Michael Brooks.
JavaScript, Fourth Edition Chapter 4 Manipulating the Browser Object Model.
TOPIC II Dynamic HTML Prepared by: Nimcan Cabd Cali.
Copyright © Terry Felke-Morris WEB DEVELOPMENT & DESIGN FOUNDATIONS WITH HTML5 7 TH EDITION Chapter 14 Key Concepts 1 Copyright © Terry Felke-Morris.
Topic 5 Windows and Frames. 2 Goals and Objectives Goals Goals Understand JavaScript window object, how popup windows work, find the browser that a client.
INTRODUCTION JavaScript can make websites more interactive, interesting, and user-friendly.
Project 5: Using Pop-Up Windows Essentials for Design JavaScript Level One Michael Brooks.
Introducing DHTML. Goals Understand the concept of DHTML as a tool for creating dynamic content Understand how to use DOM properties to make changes in.
Tutorial 11 1 JavaScript Operators and Expressions.
Chapter 10 Dynamic HTML (DHTML) JavaScript, Third Edition.
JavaScript and Ajax (JavaScript Environment) Week 6 Web site:
1 Objects In JavaScript. 2 Types of Object in JavaScript Built-in objects User Defined Objects Browser Object Document Object Model.
Chapter 13: DHTML: Object Model and Collections CIS 275—Web Application Development for Business I.
Section 10.1 Define scripting
Applied Component I Unit II Introduction of java-script
Using DHTML to Enhance Web Pages
Web Development & Design Foundations with HTML5 7th Edition
Document Object Model (DOM): Objects and Collections
Working with the Event Model
Integrating JavaScript and HTML
Introduction to DHTML, the DOM, JS review
Presentation transcript:

Copyright ©2005  Department of Computer & Information Science Beginning DHTML: Working with Browser Objects

Copyright ©2005  Department of Computer & Information Science Goals By the end of this lecture you should … Understand the differences among DHTML, BOM & DOM.Understand the differences among DHTML, BOM & DOM. Understand the basic hierarchy of JavaScript objects.Understand the basic hierarchy of JavaScript objects. Understand how to program using methods & attributes of the window, history, navigator and screen objects.Understand how to program using methods & attributes of the window, history, navigator and screen objects.

Copyright ©2005  Department of Computer & Information Science Alphabet Soup: DHTML, BOM, DOM DHTML refers to the idea of generating Web content dynamically. It relies very heavily on user input.DHTML refers to the idea of generating Web content dynamically. It relies very heavily on user input. BOM, the Browser Object Model, describes the way in which we program the different objects made available to use in a browser.BOM, the Browser Object Model, describes the way in which we program the different objects made available to use in a browser. DOM, the Document Object Model, refers to a W3C standard for programming in a web page (the document). It ignores non-standard browser objects.DOM, the Document Object Model, refers to a W3C standard for programming in a web page (the document). It ignores non-standard browser objects.

Copyright ©2005  Department of Computer & Information Science Standard Browser Objects window object locationobjecthistoryobjectdocumentobject formsobjectimagesobjectlinksobject navigatorobjectscreenobject

Copyright ©2005  Department of Computer & Information Science The window Object The window object is the frame or window that contains a web page. In addition, it represents the browser itself.The window object is the frame or window that contains a web page. In addition, it represents the browser itself. We’ve already used three window methods extensively: window.alert(), window.prompt() & window.confirm().We’ve already used three window methods extensively: window.alert(), window.prompt() & window.confirm().

Copyright ©2005  Department of Computer & Information Science The defaultStatus Attribute We can update the window.defaultStatus attribute to change the text of a browser window’s status bar (IMPORTANT NOTE: Be certain that status bar is viewable and that Security Features that disable JavaScript access to the status bar are temporarily turned off).We can update the window.defaultStatus attribute to change the text of a browser window’s status bar (IMPORTANT NOTE: Be certain that status bar is viewable and that Security Features that disable JavaScript access to the status bar are temporarily turned off). General Form: window.defaultStatus = new string;General Form: window.defaultStatus = new string;

Copyright ©2005  Department of Computer & Information Science Take the next few minutes to examine the file called DHTMLBrowserObjects_01. html.

Copyright ©2005  Department of Computer & Information Science The setInterval() Method Allows us to automatically repeat a function call at a specified number of milliseconds. Returns an “interval” object, which the window.clearInterval() method needs to stop the repetition: object = setInterval(“function()”, millisecond delay)Allows us to automatically repeat a function call at a specified number of milliseconds. Returns an “interval” object, which the window.clearInterval() method needs to stop the repetition: object = setInterval(“function()”, millisecond delay)

Copyright ©2005  Department of Computer & Information Science The Date Object Although not central to the BOM, the Date object is useful for things like last modified date, calendars, clocks, etc.Although not central to the BOM, the Date object is useful for things like last modified date, calendars, clocks, etc. Useful Date methods include getDate(), getDay(), getFullYear(), getMonth(), getHours(), getMinutes() & getSeconds()Useful Date methods include getDate(), getDay(), getFullYear(), getMonth(), getHours(), getMinutes() & getSeconds()

Copyright ©2005  Department of Computer & Information Science Take the next few minutes to examine the file called DHTMLBrowserObjects_02. html.

Copyright ©2005  Department of Computer & Information Science The history Object The history object allows programmers to write code that navigates a web browser’s history. Includes the history.go() method, which takes an integer value to indicate whether to go back (a negative value) or forward (a positive value). Also, history.back() and history.forward() allow us to program code to navigate incrementally.The history object allows programmers to write code that navigates a web browser’s history. Includes the history.go() method, which takes an integer value to indicate whether to go back (a negative value) or forward (a positive value). Also, history.back() and history.forward() allow us to program code to navigate incrementally.

Copyright ©2005  Department of Computer & Information Science Take the next few minutes to examine the file called DHTMLBrowserObjects_03. html.

Copyright ©2005  Department of Computer & Information Science The location Object The location object allows programmers to write code to change the URL of the current page, effectively navigating to a different web page. We can do this one of two ways: updating the window.location.href attribute or by invoking the window.location.replace() method. The latter will also replace the previous page in the browser’s history.The location object allows programmers to write code to change the URL of the current page, effectively navigating to a different web page. We can do this one of two ways: updating the window.location.href attribute or by invoking the window.location.replace() method. The latter will also replace the previous page in the browser’s history.

Copyright ©2005  Department of Computer & Information Science Take the next few minutes to examine the file called DHTMLBrowserObjects_04. html.

Copyright ©2005  Department of Computer & Information Science The navigator Object The navigator object allows programmers to detect important information about the application the user runs to view a web page. Attributes navigator of can return information about the browser name ( navigator.appName ) and version and the OS ( navigator.userAgent ) name and version.The navigator object allows programmers to detect important information about the application the user runs to view a web page. Attributes navigator of can return information about the browser name ( navigator.appName ) and version and the OS ( navigator.userAgent ) name and version. Useful for writing browser-detection scripts, when you need customized DHTML scripts for various browsers.Useful for writing browser-detection scripts, when you need customized DHTML scripts for various browsers.

Copyright ©2005  Department of Computer & Information Science Take the next few minutes to examine the file called DHTMLBrowserObjects_05. html.

Copyright ©2005  Department of Computer & Information Science The screen Object The screen object includes a group of useful attributes: window.screen.width window.screen.height window.screen.colorDepthThe screen object includes a group of useful attributes: window.screen.width window.screen.height window.screen.colorDepth

Copyright ©2005  Department of Computer & Information Science Take the next few minutes to examine the file called DHTMLBrowserObjects_06. html.

Copyright ©2005  Department of Computer & Information Science The event Object The event object allows us to build custom event handlers. Two specific attributes that we'll consider are: event.clientX event.clientYThe event object allows us to build custom event handlers. Two specific attributes that we'll consider are: event.clientX event.clientY The two attributes above trap the X and Y positions of a mouse for mouse events like onClick. See the next slide for an example …The two attributes above trap the X and Y positions of a mouse for mouse events like onClick. See the next slide for an example …

Copyright ©2005  Department of Computer & Information Science Take the next few minutes to examine the file called DHTMLBrowserObjects_07. html.

Copyright ©2005  Department of Computer & Information Science The document Object The document object represents the current page in a web browser’s window or frame.The document object represents the current page in a web browser’s window or frame. Central to the idea of DOM programming.Central to the idea of DOM programming. Includes a number of useful attributes in the form of built-in arrays: window.document.forms, window.document.links, & window.document.images.Includes a number of useful attributes in the form of built-in arrays: window.document.forms, window.document.links, & window.document.images. We’ll cover DOM extensively in the future.We’ll cover DOM extensively in the future.

Copyright ©2005  Department of Computer & Information Science Summary The window object is at the top of JavaScript's object hierarchy. It includes useful attributes like defaultStatus.The window object is at the top of JavaScript's object hierarchy. It includes useful attributes like defaultStatus. We can use the setInterval() and clearInterval() methods to program automatically repetitive functions.We can use the setInterval() and clearInterval() methods to program automatically repetitive functions. continued...

Copyright ©2005  Department of Computer & Information Science Summary The history object allows us tor program code that navigates a user's browser history.The history object allows us tor program code that navigates a user's browser history. The location object gives us the ability to read and/or modify the URL of the user's browser window.The location object gives us the ability to read and/or modify the URL of the user's browser window. continued...

Copyright ©2005  Department of Computer & Information Science Summary The navigator object gives us the ability to track technical information about the user's browser.The navigator object gives us the ability to track technical information about the user's browser. The screen object enables us to view technical information about the user's available visible space and color depth.The screen object enables us to view technical information about the user's available visible space and color depth. The event object allows us to write customized event handlers.The event object allows us to write customized event handlers.