Introduction to Web Site Development Steven Emory Department of Computer Science California State University, Los Angeles Lecture 9: JavaScript II.

Slides:



Advertisements
Similar presentations
JavaScript Part 6. Calling JavaScript functions on an event JavaScript doesn’t have a main function like other programming languages but we can imitate.
Advertisements

 CSS ids  Pages  Sites  HTML: class=“name”  Names may define format OR content › Either works  CAN apply multiple classes to the same tag  Multiple.
HTML and Web Page Design Presented by Frank H. Osborne, Ph. D. © 2005 ID 2950 Technology and the Young Child.
Introduction to Web Site Development Steven Emory Department of Computer Science California State University, Los Angeles Lecture 4: Tables and Frames.
Introduction to Web Site Development Steven Emory Department of Computer Science California State University, Los Angeles Lecture 3: Hyperlinks and Images.
Introduction to Web Site Development Steven Emory Department of Computer Science California State University, Los Angeles Lecture 2: More HTML.
Tutorial 13 Working with Objects and Styles. XP Objectives Learn about objects and the document object model Reference documents objects by ID, name,
(CS1301) Introduction to Computer Programming City Univ of HK / Dept of CS / Helena Wong 1. Overview of Programming and JavaScript - 1
Lecture 13. A Very Brief Introduction to HTML and XHTML, part II Instructor: Jie Yang Department of Computer Science University of Massachusetts Lowell.
INTRODUCTION TO CLIENT-SIDE WEB PROGRAMMING ACM 511 ACM 262 Course Notes.
D2L Notes Be sure to submit your link in the dropbox provided on D2L You can just upload an empty text file if a file upload is required Do not use D2L.
Title, meta, link, script.  The title looks like:  The tag defines the title of the document in the browser toolbar.  It also: ◦ Provides a title for.
Lab 3: Language Structures User Interface Lab: GUI Lab Sep. 9 th, 2014.
Integrating JavaScript and HTML5 HTML5 & CSS 7 th Edition.
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.
Introduction to HTML. What is a HTML File?  HTML stands for Hyper Text Markup Language  An HTML file is a text file containing small markup tags  The.
Manipulating the DOM CST 200 – JavaScript 3 –
HTML I An Introduction to the Language of the Web Terry Bake
JavaScript – The DOM JavaScript is object based The browser is object based – We can access the browser's objects in the same way we did JavaScript's Two.
JavaScript, Fourth Edition
INTRODUCTION TO JAVASCRIPT AND DOM Internet Engineering Spring 2012.
Extending HTML CPSC 120 Principles of Computer Science April 9, 2012.
Introduction to Cascading Style-sheets (CSS) Basharat Mahm ood, Department of Computer Science, CIIT,Islamabad, Pakistan 1.
DHTML - Introduction Chapter Introduction to DHTML, the DOM, JS review.
DHTML: Working with Objects Creating a Dynamic Web Page.
PHP Form Introduction Getting User Information Text Input.
INT222 - Internet Fundamentals Shi, Yue (Sunny) Office: T2095 SENECA COLLEGE.
CS-3432 Electronic Commerce Lecture – 7 Sikandar Shujah Toor
Introduction to Programming the WWW I CMSC Winter 2003 Lecture 10.
HTML.
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.
Advanced DOM Builds on last presentation on DOM Allows you to dynamically create elements and position them on a page DOM methods/properties are W3C standard.
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.
Are You Smarter Than a 5 th Grader? 1,000,000 5th Grade HTML 5th Grade Syntax 4th Grade HTML 4th Grade Syntax 3rd Grade HTML 3rd Grade Syntax 2nd Grade.
 Scripts that execute in response to some event  User clicking on something  Script does NOT execute as part of page loading  DOM facilities like.
Introduction to Web Site Development John Hurley Department of Computer Science California State University, Los Angeles Lecture 4: Favicons Tables and.
School of Computing and Information Systems CS 371 Web Application Programming JavaScript - DOM Modifying the Page from within.
Javascript Overview. What is Javascript? May be one of the most popular programming languages ever Runs in the browser, not on the server All modern browsers.
Document Object Model Nasrullah. DOM When a page is loaded,browser creates a Document Object Model of the Page.
HTML DOM Basharat Mahmood, Department of Computer Science, CIIT, Islamabad, Pakistan 1.
JavaScript Object Model. Biggest Advantage of JavaScript  I can access values of HTML elements using JavaScript  I can modify values of HTML elements.
Department of Computer Science, Florida State University CGS 3066: Web Programming and Design Spring
Chapter 10 Dynamic HTML (DHTML) JavaScript, Third Edition.
Lecture 8 Introduction to Web Programming. Announcement  First In-class exam will be on Oct. 10 (Wednesday)  2.50pm – 4.05pm  Exam will cover all materials.
Basic HTML Page 1. First Open Windows Notepad to type your HTML code 2.
Introduction to Web Site Development Department of Computer Science California State University, Los Angeles Lecture 9: JavaScript.
INTRODUCTION ABOUT DIV Most websites have put their content in multiple columns. Multiple columns are created by using or elements. The div element is.
Tarik Booker CS 120 California State University, Los Angeles.
IS2802 Introduction to Multimedia Applications for Business Lecture 6: JavaScript and Dynamic HTML Rob Gleasure
Web Basics: HTML/CSS/JavaScript What are they?
Week 3: Introduction to Javascript
>> JavaScript: Document Object Model
CIIT-Human Computer Interaction-CSC456-Fall-2015-Mr
Week 4: Introduction to Javascript
CS 371 Web Application Programming
Concepts of HTML, CSS and Javascript
Intro to JavaScript CS 1150 Spring 2017.
Introduction to Web Site Development
Introduction to Internet Programming
CT Web Development, Colorado State University
Introduction to HTML5.
Chengyu Sun California State University, Los Angeles
JavaScript.
Murach's JavaScript and jQuery (3rd Ed.)
JavaScript: BOM and DOM CS Programming Languages for Web Applications
Murach's JavaScript and jQuery (3rd Ed.)
Presentation transcript:

Introduction to Web Site Development Steven Emory Department of Computer Science California State University, Los Angeles Lecture 9: JavaScript II

Remember! JavaScript is case-sensitive Everything we have been doing this week and last is case-sensitive If you misspell anything… you are doomed… things will stop working… you will loose hair… and lots of it… like your instructor…

The Document Object Every HTML page has a document object associated with it The document object gives us access to the other HTML objects in our document, plus a few other things The syntax is: document.attribute document.function-name(parameters)

Read/Write Document Attributes document.title The title of the HTML document, usually the string that is displayed in the browser’s window caption or tab bar document.dir The general direction of text in the document; can be the string "ltr" or "rtl" document.body An object that represents the body of the document; it is quite complicated and we’ll discuss it later

Read Only Document Attributes document.URL A string that contains the full pathname of the currently open HTML document document.lastModified A string that contains the date for which the currently open HTML document was last modified

Document Functions document.write(str) A function that allows you append HTML code to your document while it is being loaded* document.getSelection() A function that retrieves a string of text in an HTML document that has been selected by the mouse document.getElementById(id) Retrieves the HTML object associated with the given HTML id attribute; this is one of the most important functions in the HTML DOM

HTMLElement Once we get an element using the function document.getElementById, we can do a lot of different things! Change the content (innerHTML) of the element Change the attributes of the element Change the direction of the element Change the CSS class name of the element And much more

Other HTML Element Objects document.getElementByID(id) returns whatever HTML element object the ID refers to HTMLParagraphElement = HTMLTableElement = Etc. etc. there are so many of them Just look up what attributes you can change for them in Eclipse, there are too many to memorize Try to avoid using the ‘old school’ attributes and do things the ‘new school’ way whenever possible

HTMLElement Attributes All HTML objects have the following attributes, for which you can change using the HTML DOM id className title dir innerHTML Inner HTML is the content between the start and end tags of an HTML element

How to Change CSS Styles Create an HTML element, say a P element Assign an ID to the element Assign a CSS class name to the element Get a handle to the HTML element using the document.getElementByID(ID) function Assign a new class name to handle.className

How to Change the Direction Create an HTML element, say a P element Assign an ID to the element Assign a DIR to the element Get a handle to the HTML element using the document.getElementByID(ID) function Assign a new direction to handle.dir You may use "LTR" or "RTL"

How to Change the Tooltip Create an HTML element, say an IMG element Assign an ID to the element Assign a TITLE to the element Get a handle to the HTML element using the document.getElementByID(ID) function Assign a new title to handle.title

How to Change Inner HTML Create an HTML element, say a P element with some content in it Assign an ID to the element Get a handle to the HTML element using the document.getElementByID(ID) function Assign new content using handle.innerHTML The innerHTML in this case is a string that can even contain HTML code in it!