Week 3: Introduction to Javascript

Slides:



Advertisements
Similar presentations
COMPSCI 345 / SOFTENG 350 TUTORIAL WEEK 8 | SAM KAVANAGH.
Advertisements

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.
JS: DOM Form Form Object Form Object –The Form object represents an HTML form. –For each instance of a tag in an HTML document, a Form object is created.
JavaScript Teppo Räisänen LIIKE/OAMK HTML, CSS, JavaScript HTML defines the structure CSS defines the layout JavaScript is used for scripting It.
JavaScript Defined DOM (Document Object Model) General Syntax Body vs. Head Variables Math & Logic Selection Functions & Events Loops Animation Getting.
Event Handlers CS101 Introduction to Computing. Learning Goals Learn about event handlers Determine how events are useful in JavaScript Discover where.
Bridges To Computing General Information: This document was created for use in the "Bridges to Computing" project of Brooklyn College. You are invited.
CNIT 133 Interactive Web Pags – JavaScript and AJAX JavaScript Environment.
Internet Mark-up Languages CO32036 Part Lecture: Elementary JavaScript.
JavaScript 1. What is JavaScript? JavaScript allows web authors to create dynamic pages that react to user interaction. It is an Object-based because.
DOM and JavaScript Aryo Pinandito.
DHTML: Dynamic HTML Internet Technology1. What is DHTML? A collection of enhancements to HTML ► To create dynamic and interactive websites Combination.
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.
Client Side Programming with JavaScript Why use client side programming? Web sides built on CGI programs can rapidly become overly complicated to maintain,
INTRODUCTION TO JAVASCRIPT AND DOM Internet Engineering Spring 2012.
Introduction to JavaScript Basharat Mahmood, Department of Computer Science, CIIT, Islamabad, Pakistan. 1.
SERVER web page repository WEB PAGE instructions stores information and instructions BROWSER retrieves web page and follows instructions Server Web Server.
Introduction to the Document Object Model DOM *Understand document structure manipulation *Dynamic effects in web pages *Programming, scripting, web content.
JavaScript Syntax, how to use it in a HTML document
JavaScript - Basic Concepts Prepared and Presented by Hienvinh Nguyen, Afshin Tiraie.
44238: Dynamic Web-site Development Client Side Programming Ian Perry Room:C48 Extension:7287
Computer Science and Software Engineering© 2014 Project Lead The Way, Inc. HTML5 Evolving Standards JavaScript.
05 – Java Script (1) Informatics Department Parahyangan Catholic University.
IS2802 Introduction to Multimedia Applications for Business Lecture 3: JavaScript and Functions Rob Gleasure
1 CSC160 Chapter 7: Events and Event Handlers. 2 Outline Event and event handlers onClick event handler onMouseOver event handler onMouseOut event handler.
INT222 - Internet Fundamentals Shi, Yue (Sunny) Office: T2095 SENECA COLLEGE.
 Scripts that execute in response to some event  User clicking on something  Script does NOT execute as part of page loading  DOM facilities like.
JavaScript Defined DOM (Document Object Model) General Syntax Body vs. Head Variables Math & Logic Selection Functions & Events Loops Animation Getting.
CIS 3.5 Lecture 2.3 "Introduction to JavaScript".
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.
Web Programming Overview. Introduction HTML is limited - it cannot manipulate data How Web pages are extended (include): –Java: an object-oriented programming.
JavaScript. JavaScript Introduction JavaScript is the world's most popular programming language. It is the language for HTML and the web, for servers,
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.
LESSON : EVENTS AND FORM VALIDATION -JAVASCRIPT. EVENTS CLICK.
Introduction to JavaScript MIS 3502, Spring 2016 Jeremy Shafer Department of MIS Fox School of Business Temple University 2/2/2016.
JavaScript and Ajax (JavaScript Environment) Week 6 Web site:
JAVASCRIPT A quick review. True False ■The DOM is a standardized way of referring to parts of a Web page. ■TRUE ■In the DOM, attributes have their own.
Introduction to Web Site Development Department of Computer Science California State University, Los Angeles Lecture 9: JavaScript.
SE-2840 Dr. Mark L. Hornick 1 Dynamic HTML Handling events from DOM objects.
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.
Introduction to JavaScript MIS 3502, Fall 2016 Jeremy Shafer Department of MIS Fox School of Business Temple University 9/29/2016.
Introduction to.
Web Basics: HTML/CSS/JavaScript What are they?
Java Script Introduction. Java Script Introduction.
Week 4: Introduction to Javascript
© 2015, Mike Murach & Associates, Inc.
Introduction to Web programming
4. Javascript Pemrograman Web I Program Studi Teknik Informatika
Introduction to JavaScript
JavaScript Introduction
DHTML Javascript Internet Technology.
A second look at JavaScript
Your 1st Programming Assignment
DHTML Javascript Internet Technology.
Functions, Regular expressions and Events
Web Design and Development
Training & Development
Javascript and JQuery SRM DSC.
E-commerce Applications Development
Code Topic 9 Standard JavaScript Events Laura Friedman
Introduction to JavaScript
Tutorial 10: Programming with javascript
Web Programming and Design
Week 5: Recap and Portfolio Site
Web Programming and Design
Web Programming and Design
Introduction to Web programming
Presentation transcript:

Week 3: Introduction to Javascript MPT Web Design Week 3: Introduction to Javascript

What will we do in this class? Extend the functionality of our webpages! We will look at the basics of JavaScript Syntax DOM Model What it can do Why we would we use it

Javascript

Questions to Ask Is there any UI elements? Can the user change the look of the page? Such as colour, font, hide/show elements. Or change HTML attributes? Can the user input a value and have a simple action performed on it? Can the user change the content on the web page?

Short Answer No

Long Answer We will use JavaScript to extend this functionality Our web pages so far have not had any UI elements and did not allow for any sort of interactivity. We will use JavaScript to extend this functionality

Where CAN we write our JavaScript? Basically anywhere on the page, as long as there’s a good reason and depending on the context

Where DO we write our JavaScript? In the head of web page in <script> tags Or in an external file which we link to using <script> tag. (similar to CSS)

What do we already know from Python? Variables Data Types Int, String, Float, Array Functions Operators + - = < > * / If / else Conditionals For Loops While Loops

What’s Different in JavaScript? Keyword function Columns and indents aren’t required - indents are still useful Function code needs to be in curly braces {} function myFunc() { code; } All lines must end with a semicolon ; Keyword var for declaring variables var myInt = 0; var myString = “Hello World”; Note Structure of For Loop Golden Rules Brought to you by Sabin Tabirca

JavaScript Syntax

For Loop if/else Example

DOM Model document.getElementById() document.getElementsByClass() We need to use the DOM Model (Document Object Model) to access elements (tags) To use the DOM we use the following bit of code: document.getElementBy… e.g. document.getElementById() document.getElementsByClass()

DOM Example HTML JavaScript Note the use of id div id=”demo” and document.getElementById(“demo”) Note the use of .innerHTML

How do we trigger/call our functions?: Events HTML events are "things" that happen to HTML elements. Events can be caused by the user or by the browser. JavaScript can "react" on the occurrence of these events. Event Description onchange An HTML element (usually input) has been changed onclick The user clicks an HTML element onmouseover The user moves the mouse over an HTML element onmouseout The user moves the mouse away from an HTML element onkeydown The user pushes a keyboard key onload The browser has finished loading the page

Event Example HTML JavaScript

Resources W3Schools JavaScript Introduction: http://www.w3schools.com/js/js_intro.asp Events in JavaScript: http://www.w3schools.com/js/js_events.asp DOM: http://www.w3schools.com/js/js_htmldom.asp