Introduction to Programming the WWW I

Slides:



Advertisements
Similar presentations
JavaScript FaaDoOEngineers.com FaaDoOEngineers.com.
Advertisements

Java Script Session1 INTRODUCTION.
Lesson 12- Unit L Programming Web Pages with JavaScript.
 2008 Pearson Education, Inc. All rights reserved Document Object Model (DOM): Objects and Collections.
1 Using jQuery JavaScript & jQuery the missing manual (Second Edition)
JavaScript CMPT 281. Outline Introduction to JavaScript Resources What is JavaScript? JavaScript in web pages.
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.
INTRODUCTION TO DHTML. TOPICS TO BE DISCUSSED……….  Introduction Introduction  UsesUses  ComponentsComponents  Difference between HTML and DHTMLDifference.
SEG3210 DHTML Tutorial. DHTML DHTML is a combination of technologies used to create dynamic and interactive Web sites. –HTML - For creating text and image.
DOM and JavaScript Aryo Pinandito.
SEG3210 DHTML Tutorial. DHTML DHTML is a combination of technologies used to create dynamic and interactive Web sites. –HTML - For creating text and image.
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.
The Document Object Model. The Web B.D, A.D. They aren’t web pages, they’re document objects A web browser interprets structured information. A server.
INTRODUCTION TO JAVASCRIPT AND DOM Internet Engineering Spring 2012.
5.2 DOM (Document Object Model). 2 Motto: To write it, it took three months; to conceive it three minutes; to collect the data in it — all my life. —F.
TUTORIAL 10: PROGRAMMING WITH JAVASCRIPT Session 2: What is JavaScript?
An Introduction to JavaScript Summarized from Chapter 6 of “Web Programming: Building Internet Applications”, 3 rd Edition.
Javascript II DOM & JSON. In an effort to create increasingly interactive experiences on the web, programmers wanted access to the functionality of browsers.
CA Professional Web Site Development Class 2: Anatomy of a Web Site and Web Page & Intro to HTML.
DHTML: Working with Objects Creating a Dynamic Web Page.
Introduction to Programming the WWW I CMSC Summer 2003 Lecture 7.
INT222 - Internet Fundamentals Shi, Yue (Sunny) Office: T2095 SENECA COLLEGE.
Introduction to the Document Object Model DOM *Understand document structure manipulation *Dynamic effects in web pages *Programming, scripting, web content.
Introduction to Programming the WWW I CMSC Winter 2003 Lecture 10.
INT222 - Internet Fundamentals Shi, Yue (Sunny) Office: T2095 SENECA COLLEGE.
1 © Netskills Quality Internet Training, University of Newcastle Using Style Sheets in Dreamweaver CS © Netskills, Quality Internet Training, University.
1 Javascript DOM Peter Atkinson. 2 Objectives Understand the nature and structure of the DOM Add and remove content from the page Access and change element.
CO1552 – Web Application Development Further JavaScript: Part 1: The Document Object Model Part 2: Functions and Events.
JavaScript Overview Developer Essentials How to Code Language Constructs The DOM concept- API, (use W3C model) Objects –properties Methods Events Applications;
JavaScript. JavaScript Introduction JavaScript is the world's most popular programming language. It is the language for HTML and the web, for servers,
Introduction to Programming the WWW I CMSC Summer 2003 Lecture 9.
Javascript Basic Concepts Presentation By: Er. Sunny Chanday Lecturer CSE/IT RBIENT.
XML DOM Week 11 Web site:
1 Using jQuery JavaScript & jQuery the missing manual (Second Edition)
DHTML.
Module 1 Introduction to JavaScript
Web Basics: HTML/CSS/JavaScript What are they?
Objective % Select and utilize tools to design and develop websites.
Getting Started with CSS
Programming Web Pages with JavaScript
Unit M Programming Web Pages with
Web Development & Design Foundations with HTML5
JavaScript is a programming language designed for Web pages.
JavaScript Event Handling.
Unit M Programming Web Pages with
W3C Web standards and Recommendations
Objective % Select and utilize tools to design and develop websites.
4. Javascript Pemrograman Web I Program Studi Teknik Informatika
Introduction to Programming the WWW I
Document Object Model (DOM): Objects and Collections
14 A Brief Look at JavaScript and jQuery.
Prepared for Md. Zakir Hossain Lecturer, CSE, DUET Prepared by Miton Chandra Datta
JavaScript Introduction
JavaScript an introduction.
DHTML Javascript Internet Technology.
DHTML Javascript Internet Technology.
Working with Dynamic Content and Styles
The Web Wizard’s Guide To JavaScript
Javascript and JQuery SRM DSC.
Introduction to DHTML, the DOM, JS review
Tutorial 10: Programming with javascript
JavaScript Basics What is JavaScript?
Web Client Side Technologies Raneem Qaddoura
Web Programming and Design
Web Programming and Design
Presentation transcript:

Introduction to Programming the WWW I CMSC 10100-01 Summer 2003 Lecture 10

Topics Today JavaScript Introduction (cont’d) Introduction to DOM

JavaScript Review Variables Arrays Methods Assignment & Comparison Operators Functions Sequence Loops for loops

Loops (cont’d) The while loop Format: Example code: Example Web page: while ( condition ) { statements;} Example code: i=5; while (i>1){ …; i-=1; } Example Web page: whileloop.html

Conditional Branching Code that makes decisions The if-else structure Test a condition One set of statements if condition is true Another set of statements if condition is false Take care to not confuse assignment (=) with equality (==) Example page: listing2.3.html

Comments Single line comments Multi-line comment block precede the line with two backslashes //A single line comment Multi-line comment block begin the comment with /* and close with */ /* A dense thicket of commentary, spanning many captivating lines of explanation and intrigue. */

Where to Placing Scripts Scripts can go in the HEAD or the BODY Event handlers in BODY send values to functions in HEAD

Code Libraries Reuse your favorite scripts Store code libraries in plain text files Use the .js extension for code libraries Reference your source libraries using the script tag Example: listing2.6.html mylibrary.js Usage: <script type="text/javascript" language=“JavaScript" src="mylibrary.js">

JavaScript Resource JavaScript Tutorial for Programmers http://wdvl.internet.com/Authoring/JavaScript/Tutorial/

The DOM DOM is Document Object Model The DOM provides an abstract description: document structure operations on a document The DOM describes several markup languages, not just HTML Vendors support this model to make Web pages interoperable The W3C DOM1 replaces proprietary DOMs from Netscape and Microsoft

DOM1 Features Use ID to assist in identifying elements <div id=“section1”>Some text</div> Access the element through document.getElementById() function Access all elements with a given tag name Use document.getElementByTagName() Example: document.getElementsByTagName(“h1”);

Document Structure The DOM specifies that a document is structured into a tree consisting of nested nodes <html> is at the top/bottom, <head><body> are its children, <p>,<h1> instances are children of <body>, etc Every item in the document is a node with a parent and possibly children

More about nodes Element nodes: Each tag is an element node Text nodes (text contained by element nodes) Text nodes may contain further children Attribute nodes (align=“center”) Attributes and text are children nodes of the node containing it <p align=“center”> Hello world</p> p align text node

Visualizing Nodes

Visualizing Nodes (tree)

Manipulating nodes JavaScript has a DOM API (application programmer interface) that allows us to access, look at, and edit attribute nodes Every element node has a style child, and this can also be edited to control everything!

Basic DOM operations document.firstchild document.getElementById() node.parentNode node.childNodes[0] node.nodeValue node.setAttribute(‘att’,’val’) node.style.<property>=“value”

Basic DOM operations (con’d) document.getElementsByTag() document.createNode() document.createTextNode() node.appendChild(aChild) node.removeChild(aChild)

Example 1: browse nodes var thenode = document.firstchild. childNodes[1].firstchild var theNode=document.getElementById("p1") theNode.parentNode theNode.parentNode.parentNode theNode.parentNode.parentNode. firstChild theNode.firstChild theNode.childNodes[0]

Example 2: update nodes Changing node text: listing3-1.html Removing and adding nodes: listing3-3.html Using loops to change nodes: listing3-5.html

Example 3: updating node style change alignment, color, and size through JavaScript buttons Note that when CSS properties are hyphenated (e.g. text-algin), JavaScript refers to them with the dash removed and the next letter capitalized (e.g. textAlign) Example Web page: styleupdates.html

Example 4: Pagewriter Use JavaScript to append nodes to a page dynamically at loading Addresses scaling issue if code is externally linked Example Web page template.html

Final Project You will put up a Web site incorporating what we have learned this quarter. It should include Several Web pages with a common look and feel induced by external style sheets and common header, footer material, navigation tools. These pages should be generated by scripts. Each page should have meaningful content, and many of them should include images and use of color for effect.

Final Project (cont’d) Tasteful use of dynamic features such as image rollovers, animations, popup HTML, dynamic menus, etc. Some portion of your code should include nontrivial server-side scripting. This could be a user database, logon system, or shopping system where state is maintained between Web pages, and where the server has to interact with data stored in a file.