Introduction to JavaScript LIS390W1A Web Technologies and Techniques 24 Oct. 2007 M. Cameron Jones.

Slides:



Advertisements
Similar presentations
JavaScript FaaDoOEngineers.com FaaDoOEngineers.com.
Advertisements

JavaScript Objects - DOM CST 200 JavaScript. Objectives Introduce JavaScript objects Introduce Document Object Model Introduce window object Introduce.
Document Object Model (DOM) JavaScript manipulation of the DOM.
Introduction to JavaScript Module 1 Client Side JS Programming M-GO Sponsored By
The Web Warrior Guide to Web Design Technologies
Project 1 Introduction to HTML.
HTML Markup language - controls appearance and content of a document Javascripts Various HTML tags.
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.
Inline, Internal, and External FIle
Introduction to JavaScript. Aim To enable you to write you first JavaScript.
INTRODUCTION TO CLIENT-SIDE WEB PROGRAMMING ACM 511 ACM 262 Course Notes.
JavaScript and The Document Object Model MMIS 656 Web Design Technologies Acknowledgements: 1.Notes from David Shrader, NSU GSCIS 2.Some material adapted.
JavaScript Teppo Räisänen LIIKE/OAMK HTML, CSS, JavaScript HTML defines the structure CSS defines the layout JavaScript is used for scripting It.
Introduction to JavaScript Dr. John P. Abraham University of Texas – Pan American.
CS346 - Javascript 1, 21 Module 1 Introduction to JavaScript CS346.
JavaScript, Fifth Edition Chapter 1 Introduction to JavaScript.
SEG3210 DHTML Tutorial. DHTML DHTML is a combination of technologies used to create dynamic and interactive Web sites. –HTML - For creating text and image.
CNIT 133 Interactive Web Pags – JavaScript and AJAX JavaScript Environment.
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.
Interacting with a Web Page using JavaScript Mat Kelly GTAI Presentation January 10, 2014.
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.
SEG3210 DHTML Tutorial. DHTML DHTML is a combination of technologies used to create dynamic and interactive Web sites. –HTML - For creating text and image.
INTRODUCTION TO JAVASCRIPT AND DOM Internet Engineering Spring 2012.
Introduction.  The scripting language most often used for client-side web development.  Influenced by many programming languages, easier for nonprogrammers.
1 JavaScript
Introduction to JavaScript CS101 Introduction to Computing.
44238: Dynamic Web-site Development Client Side Programming Ian Perry Room:C48 Extension:7287
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,
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.
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.
Review of the DOM Node properties and methods Some ways of accessing nodes Appending, copying and removing nodes Event handling – Inline – Scripting –
Creating Dynamic Webpages
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.
JavaScript Overview Developer Essentials How to Code Language Constructs The DOM concept- API, (use W3C model) Objects –properties Methods Events Applications;
CIS 3.5 Lecture 2.3 "Introduction to JavaScript".
Copyright © Terry Felke-Morris WEB DEVELOPMENT & DESIGN FOUNDATIONS WITH HTML5 7 TH EDITION Chapter 14 Key Concepts 1 Copyright © Terry Felke-Morris.
INTRODUCTION JavaScript can make websites more interactive, interesting, and user-friendly.
Web Programming Overview. Introduction HTML is limited - it cannot manipulate data How Web pages are extended (include): –Java: an object-oriented programming.
JavaScript Events Java 4 Understanding Events Events add interactivity between the web page and the user You can think of an event as a trigger that.
1 CSC160 Chapter 1: Introduction to JavaScript Chapter 2: Placing JavaScript in an HTML File.
JavaScript Events. Understanding Events Events add interactivity between the web page and the user Events add interactivity between the web page and the.
Adding Interactivity Comp 140 Fall Web 2.0 Major change in internet usage –From mostly static pages Text Graphics Simple links –To new paradigm.
Copyright © Terry Felke-Morris Web Development & Design Foundations with HTML5 8 th Edition CHAPTER 14 KEY CONCEPTS 1 Copyright.
THE DOM.
Module 1 Introduction to JavaScript
Web Basics: HTML/CSS/JavaScript What are they?
Programming Web Pages with JavaScript
Using DHTML to Enhance Web Pages
Week 4: Introduction to Javascript
Human Computer Interaction
Web Development & Design Foundations with HTML5 7th Edition
Javascript Short Introduction By Thanawat Varintree,
4. Javascript Pemrograman Web I Program Studi Teknik Informatika
Introduction to JavaScript
DHTML Javascript Internet Technology.
A second look at JavaScript
DHTML Javascript Internet Technology.
Web Design and Development
Introduction to JavaScript
Tutorial 10: Programming with javascript
Introduction to Programming and JavaScript
Introduction to JavaScript
Web Programming and Design
Creating dynamic/interactive web pages
Web Programming and Design
Introduction to Web programming
Presentation transcript:

Introduction to JavaScript LIS390W1A Web Technologies and Techniques 24 Oct M. Cameron Jones

What is JavaScript? What is HTML? Programming language for controlling the content, presentation, or behavior of a webpage (HTML document, DOM) in the user’s browser. Server LandClient Land Internet HTML + JavaScript JavaScript Interpreter

What can you do with JavaScript? Manipulate the DOM – Create, Remove, and Move nodes – Modify styles and other attributes Interact with the user – Listen for keyboard + mouse events – Process user input – Send messages to user Communicate with the server – Send and Retrieve data Interact with the browser – Detect browser version and settings – Firefox extensions are written in JavaScript

Examples

How do we create JavaScript? In the Inline with other elements In URL’s with javascript: scheme Various event attributes added to elements

My First JavaScript Create a new folder in your I-Drive courseweb_html folder called “javascript” Open TextWrangler and create a new HTML file called “helloworld.html” and save it in your javascript folder Block out a basic HTML document with a and. Add a heading in the with some message

My First JavaScript Hello world! Hello World alert("Hello World");

My Second JavaScript Move the element into the Save the file and Refresh your browser What happened? The browser interprets the HTML in a “top- down” fashion. The Javascript executes before the body has been parsed, so the headline hasn’t been displayed yet.

Some cooler JavaScript Save your file with a different name, “domexample.html” and close “helloworld.html” Popups are annoying, so let’s write our message dynamically into the webpage Delete the headline Move the element back into the body

Improved Hello World Hello world! var hello = document.createElement("h1"); var msg = document.createTextNode("Hello World"); hello.appendChild(msg); document.body.appendChild(hello);

Helloworld Autopsy Let’s read this from right to left var hello = document.createElement("h1"); Create a new element on type “ h1 ” Store that new element in a variable named hello var msg = document.createTextNode("Hello World"); Create a new text node with value “Hello World” hello.appendChild(msg); Add the text node to the h1 node we created document.body.appendChild(hello); Add the h1 node to the body of the document

General Concepts Variables – document (predefined) – hello (we defined it with var ) – msg (we defined it with var ) Strings – “ h1 ” – “ Hello World ” Functions – createElement – createTextNode – appendChild

Getting more advanced Save your file with a new name “domexample2.html” and close the old one. Move the into the Add a hyperlink in the body Say Hello

Getting tougher Hello world! function sayHello() { var hello = document.createElement("h1"); var msg = document.createTextNode("Hi"); hello.appendChild(msg); document.body.appendChild(hello); } Say Hello

Say Hello! Click the link What happened? Click the link a bunch of times What happened? The onClick attribute of the tag allows us to execute some JavaScript every time the link is clicked We are calling our “ sayHello ” function defined above in the