 Scripts that execute in response to some event  User clicking on something  Script does NOT execute as part of page loading  DOM facilities like.

Slides:



Advertisements
Similar presentations
function coffeeinfo() { document.getElementById('p3').innerHTML = "The word 'coffee' was.
Advertisements

Computer and Communication Fundamental Basic web programming Lecture 8 Rina Zviel-Girshin.
/k/k 1212 Cascading Style Sheets Part one Marko Boon
JavaScript and the DOM Les Carr COMP3001 Les Carr COMP3001.
JavaScript Part 6. Calling JavaScript functions on an event JavaScript doesn’t have a main function like other programming languages but we can imitate.
Chapter 6 © 2012 by Addison Wesley Longman, Inc Introduction Def: A dynamic HTML document is one whose tag attributes, tag contents, or element.
Georgia Institute of Technology JavaScript part 2 Barb Ericson Georgia Institute of Technology May 2006.
NAMEd anchors Enabling users to jump to specific points within Web documents.
Using Cascading Style Sheets CSS Basics. Goals Understand basic syntax of Cascading Style Sheets (CSS) Understand basic syntax of Cascading Style Sheets.
20-Jun-15 JavaScript and HTML Simple Event Handling.
Computer Science 103 Chapter 4 Advanced JavaScript.
JavaScript 101 Lesson 5: Introduction to Events. Lesson Topics Event driven programming Events and event handlers The onClick event handler for hyperlinks.
NAMEd anchors Enabling users to jump to specific points within Web documents.
Cos 381 Day 7. © 2006 Pearson Addison-Wesley. All rights reserved. 6-2 Agenda Assignment 2 Posted –Program a web-based Version of Soduku using JavaScript.
(CS1301) Introduction to Computer Programming City Univ of HK / Dept of CS / Helena Wong 1. Overview of Programming and JavaScript - 1
1 Events Lect 8. 2 Event-driven Pages one popular feature of the Web is its interactive nature e.g., you click on buttons to make windows appear e.g.,
UNIT 6 JAVASCRIPT EVENT HANDLERS &WEB BROWSERS DETECTION.
HTML Forms/Events (Instructor Lesson) The Event model HTML Forms Custom Events 1.
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.
Chapter 19: Adding JavaScript
CNIT 133 Interactive Web Pags – JavaScript and AJAX JavaScript Environment.
JavaScript Part 1.
CSS Class 7 Add JavaScript to your page Add event handlers Validate a form Open a new window Hide and show elements Swap images Debug JavaScript.
Lesson13. JavaScript JavaScript is an interpreted language, designed to function within a web browser. It can also be used on the server.
Extending HTML CPSC 120 Principles of Computer Science April 9, 2012.
Javascript II DOM & JSON. In an effort to create increasingly interactive experiences on the web, programmers wanted access to the functionality of browsers.
Lecture 10 JavaScript: DOM and Dynamic HTML Boriana Koleva Room: C54
Introduction to the Document Object Model DOM *Understand document structure manipulation *Dynamic effects in web pages *Programming, scripting, web content.
Web Development 101 Presented by John Valance
JavaScript Making Web pages come alive. Objectives Be able to read JavaScript scripts Be able to write JavaScript scripts.
Event JavaScript's interaction with HTML is handled through events that occur when the user or browser manipulates a page. When the page loads, that is.
Scripting and Interactivity 이병희
C H 07: M ORE A BOUT HTML Tharith Sriv. O UTLINE You have already learnt almost everything in HTML. In this chapter, you will learn more about:  An HTML.
By Tharith Sriv. To write a web page you use: HHTML (HyperText Markup Language), AASP (Active Server Page), PPHP (HyperText Preprocessor), JJavaScript,
Active X – Mouse Events. Structured Graphics Control  Included in Internet Explorer v5.0  Add to page with the OBJECT tag  Accessible via scripting.
HTML JAVASCRIPT. CONTENTS Javascript Example NOSCRIPT Tag Advantages Summary Exercise.
JavaScript Challenges Answers for challenges
Event Handling. Objectives Using event handlers Simulating events Using event-related methods.
Basic Webpage Design Mark-up html document with images.
COS 125 DAY 20. Agenda Assignment 8 not corrected yet Assignment 9 posted  Due April 16 New course time line Discussion on Scripts 
 Web pages originally static  Page is delivered exactly as stored on server  Same information displayed for all users, from all contexts  Dynamic.
JavaScript Functions A function is a block of code that can be reused. It is similar to a method in Java. It consists of a function name, an argument.
Copyright © Terry Felke-Morris WEB DEVELOPMENT & DESIGN FOUNDATIONS WITH HTML5 7 TH EDITION Chapter 14 Key Concepts 1 Copyright © Terry Felke-Morris.
7. JavaScript Events. 2 Motto: Do you think I can listen all day to such stuff? –Lewis Carroll.
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.
Chapter 6 © 2014 by Pearson Education Introduction Def: A dynamic HTML document is one whose tag attributes, tag contents, or element style properties.
Document Object Model Nasrullah. DOM When a page is loaded,browser creates a Document Object Model of the Page.
LESSON : EVENTS AND FORM VALIDATION -JAVASCRIPT. EVENTS CLICK.
 2001 Prentice Hall, Inc. All rights reserved. 1 Chapter 14 - Dynamic HTML: Event Model Outline 14.1 Introduction 14.2 Event onclick 14.3 Event onload.
CSC 121 Computers and Scientific Thinking Fall Event-Driven Programming.
JavaScript and Ajax (JavaScript Environment) Week 6 Web site:
Chapter 6 Dynamic Documents with JavaScript. © 2006 Pearson Addison-Wesley. All rights reserved Introduction Def: A dynamic HTML document is.
Functions Wouldn’t it be nice to be able to bring up a new animal and paragraph without having to reload the page each time? We can! We can place the.
Chapter 6 © 2003 by Addison-Wesley, Inc Introduction - Dynamic HTML is not a new markup language - A dynamic HTML document is one whose tag attributes,
Copyright © Terry Felke-Morris Web Development & Design Foundations with HTML5 8 th Edition CHAPTER 14 KEY CONCEPTS 1 Copyright.
SE-2840 Dr. Mark L. Hornick 1 Dynamic HTML Handling events from DOM objects.
Third lecture Event 27/2/2016 JavaScript Tutorial.
6.1 Introduction 6.2 Element Positioning
THE DOM.
Introduction to.
JavaScript and HTML Simple Event Handling 11-May-18.
Week 3: Introduction to Javascript
Week 4: Introduction to Javascript
Intro to JavaScript CS 1150 Spring 2017.
Web Development & Design Foundations with HTML5 7th Edition
JavaScript and HTML Simple Event Handling 19-Sep-18.
6.1 Introduction 6.2 Positioning Elements
JavaScript and HTML Simple Event Handling 26-Aug-19.
JavaScript and HTML Simple Event Handling 4-Oct-19.
Presentation transcript:

 Scripts that execute in response to some event  User clicking on something  Script does NOT execute as part of page loading  DOM facilities like document.write() are not useful  Must use DOM facilities like document.getElementById(…) to make changes 2Event-Driven Client-Side Scripting

 element – anything wrapped in an opening and closing HTML tag  attribute –  Normally defined within an element’s opening tag  Syntax: name=value  Ex: img element usually has a src attribute set to the URL/path for the image ______start tag________ / \ / ______attribute_________\ __ close tag / / \\ / \ Go Navy. \____________________________________/ element 3Event-Driven Client-Side Scripting

 HTML elements can be given a name  Use id attribute in the start tag Elements named foo and bar.  Naming elements allows us to reference them by name inside JavaScript document.getElementById(“foo”) document.getElementById(“bar”) 4Event-Driven Client-Side Scripting

 document.getElementById(…) returns an object representing the named HTML element  Can be manipulated in several ways .innerHTML .style .innerHTML  Stores whatever is located between the element’s start and end tags  If other elements are nested within the element,.innerHTML will contain tags 5Event-Driven Client-Side Scripting

.style – object that contains values that affect the way an element looks in the browser .style.color – color of text  Colors specified as RGB triples .style.background – background color .style.fontFamily – which font is used for text  Can specify specific font family or generic (e.g., serif, sans-serif, monospace) .style.fontSize – size of the displayed font  units including pt (points), px (pixels) and em (multiple of current font-size) 6Event-Driven Client-Side Scripting

 onclick  Script runs when mouse button is clicked on an element  ondblclick  Script runs when mouse button is double-clicked on the element  onmousedown  Script runs when mouse button is pressed down  Similar to onclick, but executes before the button is released  onmouseup  Script runs when mouse button is released  onmousemove  Script runs when the mouse pointer is moved  onmouseout  Script runs when mouse pointer moves out of an element  onmouseover  Script runs when mouse pointer moves over an element 7Event-Driven Client-Side Scripting