CS 371 Web Application Programming

Slides:



Advertisements
Similar presentations
Table (TABLE) Contains TABLE ROWS (TR) Contains TABLE DATA (TD) Data can contain anything Text Lists Other tables Pictures …
Advertisements

The jQuery library. What is jQuery ? A javascript lightweight library Is very easy to use Is powerful Is cross-browser compatible Downloadable from jQuery.com,
JavaScript and the DOM Les Carr COMP3001 Les Carr COMP3001.
The Document Object Model (DOM) 1 JavaScript is an object-based language—that is, it’s based on manipulating objects by changing each object’s properties.
JavaScript Part 6. Calling JavaScript functions on an event JavaScript doesn’t have a main function like other programming languages but we can imitate.
CS7026 jQuery Events. What are Events?  jQuery is tailor-made to respond to events in an HTML page.  Events are actions that can be detected by your.
CS134 Web Design & Development Attributes, Lists, Tables, Links, and Images Mehmud Abliz.
 2008 Pearson Education, Inc. All rights reserved Document Object Model (DOM): Objects and Collections.
HTML DOM.  The HTML DOM defines a standard way for accessing and manipulating HTML documents.  The DOM presents an HTML document as a tree- structure.
JS: Document Object Model (DOM)
1 The Document Object Model SAMS Teach Yourself JavaScript in 24 Hours (Fourth Edition) Michael Moncur SAMS Publishing 2007.
Test Automation For Web-Based Applications Portnov Computer School Presenter: Ellie Skobel.
JavaScript & DOM Client-side scripting. JavaScript JavaScript is a tool to automate client side (which is implemented using HTML so far) JavaSript syntax.
UFCEWT-20-3 Advanced Topics in Web Development Lecture 4 : JavaScript, Browsers & the HTML DOM-API.
DOM and JavaScript Aryo Pinandito.
Lecture 11 – DOM Scripting SFDV3011 – Advanced Web Development Reference: 1.
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.
Manipulating the DOM CST 200 – JavaScript 3 –
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.
Javascript II DOM & JSON. In an effort to create increasingly interactive experiences on the web, programmers wanted access to the functionality of browsers.
Copyright 2007, Information Builders. Slide 1 Understanding Basic HTML Amanda Regan Technical Director June, 2008.
Internet & World Wide Web How to Program, 5/e. © by Pearson Education, Inc. All Rights Reserved.
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.
 2008 Pearson Education, Inc. All rights reserved Document Object Model (DOM): Objects and Collections.
Review of the DOM Node properties and methods Some ways of accessing nodes Appending, copying and removing nodes Event handling – Inline – Scripting –
INT222 - Internet Fundamentals Shi, Yue (Sunny) Office: T2095 SENECA COLLEGE.
Rich Internet Applications 3. Client JavaScript. Document Object Model (DOM) The DOM, is an interface that allows scripts or programs to access and manipulate.
DOM (Document Object Model) - Parsing and Reading HTML and XML -
School of Computing and Information Systems CS 371 Web Application Programming JavaScript - DOM Modifying the Page from within.
HTML CS 105. Page Structure HTML elements control the details of how a page gets displayed. Every HTML document has the following basic structure: … …
1 Javascript CS , Spring What is Javascript ? Browser scripting language  Dynamic page creation  Interactive  Embedded into HTML pages.
Understanding JavaScript and Coding Essentials Lesson 8.
Document Object Model Nasrullah. DOM When a page is loaded,browser creates a Document Object Model of the Page.
JS: Document Object Model (DOM) DOM stands for Document Object Model, and allows programmers generic access to: DOM stands for Document Object Model, and.
This is our seminar JavaScript And DOM This is our seminar JavaScript And DOM.
Chapter 6 Murach's JavaScript and jQuery, C6© 2012, Mike Murach & Associates, Inc.Slide 1.
XML DOM Week 11 Web site:
DOM Dr. Reda Salama. Back to the HTML DOM Once we get a response back from the server, we probably want to update our HTML page The HTML page itself is.
HTML Help book. HTML HTML is the programming language used to make web pages for the Internet. HTML stands for Hyper Text Markup Language. HTML is made.
Introduction to JavaScript DOM Instructor: Sergey Goldman.
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.
Java Script and the DOM DOM stands for: –The Document Object Model When a browser reads a web page, it converts it’s contents from HTML into a hierarchical.
THE DOM.
>> JavaScript: Document Object Model
CIIT-Human Computer Interaction-CSC456-Fall-2015-Mr
Elements of HTML Web Design – Sec 3-2
Week 4: Introduction to Javascript
Scripting the DOM MIS 3502, Fall 2016 Jeremy Shafer Department of MIS
CGS 3066: Web Programming and Design Spring 2017
Applied Online Programming
CGS 3066: Web Programming and Design Spring 2016
Intro to JavaScript CS 1150 Spring 2017.
The Web Wizard’s Guide To DHTML and CSS
Week 11 Web site: XML DOM Week 11 Web site:
Tutorial 6 Creating Dynamic Pages
CHAPTER 7 JavaScripts & HTML Documents
Working with Dynamic Content and Styles
© 2015, Mike Murach & Associates, Inc.
LING 408/508: Computational Techniques for Linguists
Introduction to HTML.
Javascript and JQuery SRM DSC.
Chengyu Sun California State University, Los Angeles
CS7026 jQuery Events.
CHAPTER 6 EVENTS. CHAPTER 6 EVENTS WHAT IS AN EVENT?
Week 5: Recap and Portfolio Site
JavaScript: BOM and DOM CS Programming Languages for Web Applications
JavaScript and the DOM MIS 2402 Maxwell Furman Department of MIS
Presentation transcript:

CS 371 Web Application Programming JavaScript - DOM Modifying the Page from within CS 371 Web Application Programming

JavaScript events events are associated with many elements of a page <li onclick=“funct(1)”>blah…</li> events associated with click, double-click, focus, errors keyboard, hover, mousemove, resize, scroll,… return false to cancel the default action (submitting a form, following a link, etc) events will be fired all the way up the chain (e.g. li, then ul, then div, then document…) CS 371 Web Application Programming

replace the content of a tag with html code example: innerHTML replace the content of a tag with html code example: var obj=document.getElementById(“myId”); obj.innerHTML=“<p class='wow'>wassup</p>” CS 371 Web Application Programming

JavaScript DOM JavaScript built-in objects Intro to the DOM collections methods techniques: insert html modify table or list values change structure of tables or lists change form elements CS 371 Web Application Programming

Document Object Model contains collections, objects, methods anchors[ ] - all anchor tags forms[ ] - information about forms images[ ] - about images links[ ] - includes <a> and <area> tags objects (document.cookie, .title, etc.) methods like getElementsByTagName CS 371 Web Application Programming

JavaScript DOM document methods document.write inserts text in the web page data is written at the point it is executed document.open, close open starts a new document close ends it and displays the new document CS 371 Web Application Programming

JavaScript DOM document properties document.cookie – saw this earlier document.domain document.readyState is the page still loading? document.title others… CS 371 Web Application Programming

JavaScript DOM document methods (cont.) document.getElementsByTagName document.getElementById document.getElementsByName example in javascript: document.getElementById(“x”).innerHTML= “<b>wow</b>” in html: <div id=“x></div> CS 371 Web Application Programming

JavaScript DOM document methods (cont.) assign to objects: var divObj=document.getElementById(“x”); divObj.innerHTML=“stuff” properties: attributes[ ] childNodes[ ] firstChild nodeValue style many others… CS 371 Web Application Programming

JavaScript DOM document methods (cont.) attributes var divObj=document.getElementById(“x”); if(divObj.attributes[0].nodeName==“alt”); alert(divObj.attributes[i].nodeValue); divObj.setAttribute(“class”,”pizzaz”); divObj.removeAttribute(“align”); CS 371 Web Application Programming

JavaScript DOM document methods (cont.) child elements: var divObj=document.getElementById(“x”); alert(divObj.childNodes[0].nodeValue); for(var i=0; i<divObj.childNodes.length; i++) divObj.removeChild(0); divObj.appendChild(document.createElement (“p”)); var txt=document.createTextNode(“Stuff”); divObj.childNodes[0].appendChild(txt); CS 371 Web Application Programming

JavaScript DOM table properties cells[ ] rows[ ] border, bgColor, etc tr properties methods table: insertRow(x), deleteRow(x), moveRow tr: insertCell, deleteCell CS 371 Web Application Programming

JavaScript DOM table examples insert rows var tab=document.getElementsByTagName (“table”)[0]; var myRow=tab.insertRow(-1); var myCell=myRow.insertCell(0); myCell.appendChild( document.createTextNode(“cell data”)); delete rows tab.deleteRow(0); CS 371 Web Application Programming