JavaScript II CSCI 311 SPRING 2017

Similar documents
JavaScript: Events, DOM and Attaching Handlers

Web Programming and Design. MPT Junior Cycle Tutor: Tamara Demonstrators: Aaron, Marion, Hugh

Session 7. JavaScript Part 2. W3C DOM Reading and Reference

COMP519 Web Programming Lecture 16: JavaScript (Part 7) Handouts

Recall: Document Object Model (DOM)

5/19/2015. Objectives. JavaScript, Sixth Edition. Understanding the Browser Object Model and the Document Object Model. Objectives (cont'd.

JavaScript and XHTML. Prof. D. Krupesha, PESIT, Bangalore

JavaScript 3. Working with the Document Object Model (DOM) and DHTML

Introduction to HTML & CSS. Instructor: Beck Johnson Week 5

HTML 5 and CSS 3, Illustrated Complete. Unit L: Programming Web Pages with JavaScript

8/19/2018. Web Development & Design Foundations with HTML5. Learning Objectives (1 of 2) Learning Objectives (2 of 2) What is JavaScript?

CE212 Web Application Programming Part 2

JavaScript is described in detail in many books on the subject, and there is excellent tutorial material at

HTML + CSS. ScottyLabs WDW. Overview HTML Tags CSS Properties Resources

UI Course HTML: (Html, CSS, JavaScript, JQuery, Bootstrap, AngularJS) Introduction. The World Wide Web (WWW) and history of HTML

WEB DESIGNING COURSE SYLLABUS

729G26 Interaction Programming. Lecture 4

Modules Documentation ADMAN. Phaistos Networks


HTML5. HTML5 Introduction. Form Input Types. Semantic Elements. Form Attributes. Form Elements. Month Number Range Search Tel Url Time Week

Best Practices Chapter 5

HTML CS 4640 Programming Languages for Web Applications

Elementary Computing CSC 100. M. Cheng, Computer Science

Document Object Model. Overview

CSC Web Programming. JavaScript Browser Objects

Outline. Lecture 4: Document Object Model (DOM) What is DOM Traversal and Modification Events and Event Handling

Sections and Articles

HTML & CSS. SWE 432, Fall 2017 Design and Implementation of Software for the Web

Document Object Model (DOM)

DNNGo LayerSlider3D. User Manual

Introduction to using HTML to design webpages

Programing for Digital Media EE1707. Lecture 4 JavaScript By: A. Mousavi & P. Broomhead SERG, School of Engineering Design, Brunel University, UK

Review of HTML. Chapter Pearson. Fundamentals of Web Development. Randy Connolly and Ricardo Hoar

CSI 3140 WWW Structures, Techniques and Standards. Browsers and the DOM

Programming Lab 1 (JS Hwk 3) Due Thursday, April 28

Skyway Builder Web Control Guide

INDEX SYMBOLS See also

HTML User Interface Controls. Interactive HTML user interfaces. Document Object Model (DOM)

Website Development with HTML5, CSS and Bootstrap

Overview. Event Handling. Introduction. Reviewing the load Event. Event mousemove and the event Object. Rollovers with mouseover and mouseout

HTML5, CSS3, JQUERY SYLLABUS

E ECMAScript, 21 elements collection, HTML, 30 31, 31. Index 161

Pearson Education Limited Edinburgh Gate Harlow Essex CM20 2JE England and Associated Companies throughout the world

INLEDANDE WEBBPROGRAMMERING MED JAVASCRIPT INTRODUCTION TO WEB PROGRAMING USING JAVASCRIPT

Index LICENSED PRODUCT NOT FOR RESALE

(try adding using css to add some space between the bottom of the art div and the reset button, this can be done using Margins)

Events: another simple example

Web Development & Design Foundations with HTML5

Welcome Please sit on alternating rows. powered by lucid & no.dots.nl/student

Markup Language. Made up of elements Elements create a document tree

DOM. Contents. Sergio Luján Mora. What is DOM? DOM Levels DOM Level 0 DOM Level 1. Departamento de Lenguajes y Sistemas Informáticos

Web Designing Course

JAVASCRIPT AND JQUERY: AN INTRODUCTION (WEB PROGRAMMING, X452.1)

of numbers, converting into strings, of objects creating, sorting, scrolling images using, sorting, elements of object

Cascading style sheets, HTML, DOM and Javascript

CSC Javascript

showinplaceholder The jquery Plug-in

Lecture : 3. Practical : 2. Course Credit. Tutorial : 0. Total : 5. Course Learning Outcomes

PHP,HTML5, CSS3, JQUERY SYLLABUS

Photo from DOM

Chapter 9 Introducing JQuery

710 Index Attributes, 127 action attribute, 263 assigning, bottom attribute, domain name attribute, 481 expiration date attribute, 480 8

Standard 1 The student will author web pages using the HyperText Markup Language (HTML)

Dynamic documents with JavaScript

CIS 228 (Spring, 2012) Final, 5/17/12

Elementary Computing CSC 100. M. Cheng, Computer Science

Web Site Development with HTML/JavaScrip

The ActionScript Markup Language

CITS3403 Agile Web Development Semester 1, 2018

Make a Website. A complex guide to building a website through continuing the fundamentals of HTML & CSS. Created by Michael Parekh 1

Introduction to DHTML

jquery Tutorial for Beginners: Nothing But the Goods

COMS W3101: SCRIPTING LANGUAGES: JAVASCRIPT (FALL 2018)

VTEM SLIDES INSTRUCTION MANUAL COPYRIGHT DISCLAIMER. Instruction Manual FOR INFO, UPDATES, REQUESTS & CONTACT

Programmazione Web a.a. 2017/2018 HTML5

Assignments (4) Assessment as per Schedule (2)

Interactor Tree. Edith Law & Mike Terry

1.264 Lecture 12. HTML Introduction to FrontPage

Web Programming Step by Step

New Perspectives on Creating Web Pages with HTML. Tutorial Objectives

Javascript Lecture 23

How to create interactive documents

1. Cascading Style Sheet and JavaScript

JavaScript I.b CSCI311

As we design and build out our HTML pages, there are some basics that we may follow for each page, site, and application.

Produced by. App Development & Modeling. BSc in Applied Computing. Eamonn de Leastar

An Brief Introduction to a web browser's Document Object Model (DOM) Lecture 24

itunes Extras/iTunes LP Development: TuneKit Programming Guide v1.0

Using Dreamweaver CS6

FBCA-03 April Introduction to Internet and HTML Scripting (New Course)

CICS 515 a Internet Programming Week 3. Mike Feeley

CUSTOMER PORTAL. Custom HTML splashpage Guide

CS193X: Web Programming Fundamentals

Step 1: Add New Tooltip Module

Understanding this structure is pretty straightforward, but nonetheless crucial to working with HTML, CSS, and JavaScript.

Introduction to. Maurizio Tesconi May 13, 2015

PHP / MYSQL DURATION: 2 MONTHS

JavaScript Handling Events Page 1

The Benefits of CSS. Less work: Change look of the whole site with one edit

Introduction to HTML & CSS. Instructor: Beck Johnson Week 2

Transcription:

JavaScript II CSCI 311 SPRING 2017

Overview Look at more JavaScript functionality DOM slide show preloading images pull down menus and more!

Document Object Model DOM gives us ways to access elements of HTML from JavaScript (and other scripts) windows, documents, elements, attributes, text, events, style sheets and rules DOM tree elements in HTML are tree nodes organized into hierarchy from a node you can traverse down or up can add, modify, remove any elements from tree can get and set content attributes access, change, delete, add style elements

DOM tree Root is the Document node accessible via document or window.document for example: document.getelementbyid( idname ); HTML/XML markup elements: gives access to elements of the HTML and their attributes and children innerhtml: for non-void elements, setting innerhtml changes the code in that element Accessing an element s attributes: element.attributes.xyz element.getattribute( xyz ); element.setattribute( xyz, value);

Example var p=document.getelementbyid( para ); var tx=p.firstchild; alert(tx.data); alert(tx.wholetext); <body style="margin: 50px" onload="showme()"> <section> <h1>text Nodes</h1> <p id="para">here is an <strong>example</strong> of <span style="color: blue">marked up text</span> in a paragraph.</p> </section> </body> </html>

More examples <section><h1>dom Calculator</h1> <p>simply type in a string such as <code>32 + 98 * 6</code> and click GO.</p> <p><strong>compute : </strong> <input required="" id="uin" placeholder="(20-12) * 6" maxlength="30" /> <input id="go" value="go" type="button onclick="comp('uin')" /> </p> <p id="par">and the answer is: <span id="ans" class="ans">48</span></p> </section>

HTMLElement Fields and Methods tagname readonly representation of tag name style style object for an element set to empty string to set to inherited or default set to a value to an individual style property to change it classname innerhtml getattribute/setattribute/removeattribute/hasattribute focus() to gain focus for input element blur() lose focus

document methods write or writeln createelement createtextnode getelementbyid getelementsbytagname getelementsbyname getelementsbyclassname (can pass comma-separated list of classes)

Generating New Content Build a data-recording calculator A smart Form A sorting shopping cart

Building elements dynamically A couple more demos to build a list of selections with JavaScript

Preloading Images Quick response to mouseover may require the image to preloaded To avoid delays, images may be able to be preloaded: function loadimage(url) { if (document.images) // if browser supports images } { img = new Image(); // obtains a new image object img.src = url; // downloads the image return img; } Script with above placed in head triggered by the onload event in the body element

Slideshow We can easily make a slideshow using the click event Example: Slides.html, slide.css, slide.js Example: slideshow.html

Example: Conversion Calculator Two inputs of type number onfocus event triggers the method call: reset() a button onclick event triggers convert() method call convert.js

Pull-down menus with JavaScript Pull-down menu example will use: horizontal navbar html fragment file with one or more menus. Each is a nav element with child links style sheet for navbar and menus JavaScript file with pull-down and pull-up actions Table-styled page layout

Pull-down Menu Horizontal navbar lines 19-27 5 links: Main, Service, and Contact are conventional anchor elements <a> Activity and Location are spans with onclick events, and onmouseover events that call functions in menuup.js The JavaScript part: menus only work as mouseovers if activated to be activated, they must be clicked to deactivate, click an activated menu item only one pull-down shows at a time in down method, any current menu is pulled up first

Pull-down menu Offsets: y offset is set relative to context box below set in init method x position is from the menu item itself xposition method goes up the offset parent chain sums the offsets in this case it is the x value of the menu + the offset of the parent (body with offset of 0) in our case dx and dy are both 0

CSS Transitions We can use CSS to change a style smoothly from one to another over a given amount of time general form: transition: property duration fn, comma separated list of properties or use all timing function can be linear, or cubic-bezier predefined timing functions: linear ease ease-in ease-out ease-in-out

Adding transitions to pull-down menu Let s add fade-in and fade-out to pull-down menu MenuFade.html change the css for the menu (found in transition.css) Change the JavaScript too: down method add settimeout(showdisplay, 50) schedules a call to the showdisplay function in 50 milliseconds in this method, we transition the opacity to 1 pull up does the same, but the reverse the amount of time for deltay to calling nodisplay is slightly longer than the fade out time

Another Menu Unlike previous example, pulldown menus are not on mouse over (but you could do that) have 2 nav elements at bottom of html that are hidden by default (in css) nav.menu display:none on click event in 2 of the menu items calls JavaScript function

Summary Seen more advanced JavaScript that can be used to implement user interaction dynamic pages dropdown menus slide shows