Loops Pretest var i=1, sum=0; while (i<5) { sum += i++; } alert(sum); Counter controlled var i=0, sum=0; for (i=1; i<=5; i++) sum += I; alert(sum); Post-test.

Slides:



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

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.
Part 5 Introduction to CSS. CSS Display - Block and Inline Elements A block element is an element that takes up the full width available, and has a line.
CGS 3175: Internet Applications (CSS – Page Layout) Page 1 © Mark Llewellyn CGS 3175: Internet Applications Fall 2008 Cascading Style Sheets – Page Layout.
CSS provides a way to stray away from the traditional methods of using tables to lay out pages. Success with this technique depends on understanding of.
Using CSS for Page Layout. Types of HTML Elements Block-Level Element –Creates blocks of content e.g. div, h1..h6, p, ul, ol, li, table, form –They start.
Lecture 6 8/11/11.
1 Javascrbipt Intro Javascript (or js) is a programming language. Interpreted, not compiled. Not the same as java, but, similar. Use tags to use. Object-oriented.
AJAX (Asynchronous JavaScript and XML) Amit Jain CS 590 – Winter 2008.
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.
Chapter 9 Introduction to the Document Object Model (DOM) JavaScript, Third Edition.
CHAPTER 24 PERFORMING CSS TRANSITIONS AND ANIMATIONS.
1 Forms A form is the usual way that information is gotten from a browser to a server –HTML has tags to create a collection of objects that implement this.
HTML basics exercises.
Webpage design for researchers Dr Jim Briggs 1.
JavaScript Defined DOM (Document Object Model) General Syntax Body vs. Head Variables Math & Logic Selection Functions & Events Loops Animation Getting.
Advanced Web Design Scripting Tutorial Chapters. Scripting Intro The scripting part of the forthcoming Advanced Web Design textbook introduces you to.
Bridges To Computing General Information: This document was created for use in the "Bridges to Computing" project of Brooklyn College. You are invited.
© 2000 – All Rights Reserved - Page 1 Introduction to JavaScript Programming Part Two.
Chapter 10 Creating Pop-Up Windows, Adding Scrolling Messages, and Validating Forms HTML5 & CSS 7 th Edition.
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.
HTML: Tables & Frames Internet Technology1. HTML: Tables Table tags ► surround the entire table ► header row (text is boldfaced) ► surround each row ►
CITS1231 Web Technologies JavaScript and Document Object Model.
JavaScript, Fourth Edition
 2001 Deitel & Associates, Inc. All rights reserved. 1 Chapter 20 – Dynamic HTML: Object Model and Collections Outline 20.1Introduction 20.2Object Referencing.
Chapter 5: Windows and Frames
HTML: Tables & Frames Internet Technology.
Dynamic Web Authoring JavaScript – Array and function (2) COM311H Zheng, School of C&M, UUJ1.
HTML.
JavaScript, Fourth Edition Chapter 4 Manipulating the Browser Object Model.
1 Chapter 3 – JavaScript Outline Introduction Flowcharts Control Structures if Selection Structure if/else Selection Structure while Repetition Structure.
HTML JAVASCRIPT. CONTENTS Javascript Example NOSCRIPT Tag Advantages Summary Exercise.
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 Defined DOM (Document Object Model) General Syntax Body vs. Head Variables Math & Logic Selection Functions & Events Loops Animation Getting.
Cascading Style Sheets (CSS) Part II IT210: Web-based IT.
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.
CIS 3.5 Lecture 2.3 "Introduction to JavaScript".
Chapter 7 - JavaScript: Introduction to Scripting Outline 7.1 Introduction 7.2 Simple Program: Printing a Line of Text in a Web Page 7.3 Another JavaScript.
School of Computing and Information Systems CS 371 Web Application Programming JavaScript - DOM Modifying the Page from within.
INTRODUCTION JavaScript can make websites more interactive, interesting, and user-friendly.
JavaScript V Robin Burke ECT 270. Outline Manipulating style Special effect examples.
Project Two Adding Scrolling Messages! Page 2.4 to 2.18 Today’s Agenda Look at scrolling message coding. Create a web page with a text box. Create a web.
Styles for webpages. Multi-column layout #navcol {position: absolute; top: 5px; left: 5px; width:260px; background-color: black; border:none; z-Index:0}
CIS67 Foundations for Creating Web Pages Professor Al Fichera Rev. September 22, 2010—All HTML code brought to XHTML standards. Reference for CIS127 and.
Chapter 6 Murach's JavaScript and jQuery, C6© 2012, Mike Murach & Associates, Inc.Slide 1.
Link. setTimeout() What if you want to automatically cycle through the pics? So you don’t have to keep clicking the button to see the next pic Use the.
Introduction to JavaScript LIS390W1A Web Technologies and Techniques 24 Oct M. Cameron Jones.
CIS67 Foundations for Creating Web Pages Professor Al Fichera Rev. August 25, 2010—All HTML code brought to XHTML standards. Reference for CIS127 and CIS.
JavaScript IV Robin Burke ECT 270. Outline Final project reminder Style review Manipulating style Special effect examples.
Adding Interactivity Comp 140 Fall Web 2.0 Major change in internet usage –From mostly static pages Text Graphics Simple links –To new paradigm.
JavaScript: A short introduction Joseph Lee Created by Joseph Lee.
Project 02 Creating and Editing a Web Page Concept Map of Unit Creating and Editing a Web Page Key Learning Understand the elements to create a web page.
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.
Cascading Styles Sheets Positioning HTML elements.
INTRODUCTION ABOUT DIV Most websites have put their content in multiple columns. Multiple columns are created by using or elements. The div element is.
Changing CSS Styles via JavaScript No readings?. 2 Review? You can change the CSS styling of an element with JavaScript Syntax is similar to accessing.
 2001 Prentice Hall, Inc. All rights reserved. Outline 1 JavaScript.
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.
Tutorial 4 Using CSS for Page Layout. Objectives Session 4.1 – Explore CSS layout – Compare types of floating layouts – Examine code for CSS layouts –
Web Basics: HTML/CSS/JavaScript What are they?
Advanced CSS & CSS3.
Creating Your Book Review Web Site
Scrolling text repeating until end of slide.
MORE Cascading Style Sheets (The Positioning Model)
Book / movie report Web design.
If the person is married and has more than 5 dependents MOVE MSG-1 TO MSG-PR, if the person is married and does not have more than 5 dependents MOVE MSG-2.
Advanced CSS.
Introduction to JavaScript
Cascading Style Sheets
Presentation transcript:

Loops Pretest var i=1, sum=0; while (i<5) { sum += i++; } alert(sum); Counter controlled var i=0, sum=0; for (i=1; i<=5; i++) sum += I; alert(sum); Post-test loop var i=0, sum=0; do { sum += i++; } while (i<=5); alert(sum); Questions –Print "Hello" 100 times –Count backwards from 100 to 1 –Lets do some examples in the book Computers often need to repeat the same thing over and over

Move the Mouse div {position:absolute; left:0px; top:100px; width:100px; height:100px; } var position=-95; var speed = Math.floor(Math.random()*10)+2; function next() { position+=speed; if (position>795) position=-95; document.getElementById("mouse").style.left=position + 'px'; window.setTimeout("next();",10); } Animation A Moving Mouse Modify the position of the tag and repeatedly call the next() function every 10 milliseconds using calls to setTimeout()

A Scrolling Message var middle = 0; var msg = "This is an example of a scrolling message. "; function ScrollIt() { var text = msg.substring(middle, msg.length) +msg.substring(0,middle); var td = document.getElementById("scroll"); td.innerHTML = text; if (++pos > msg.length) pos = 0; window.setTimeout("ScrollIt()",200); } Repeat every fifth of a second Concept: display from middle to end, and then from front to middle

Review Questions 1.What are the three kind of loops? How do you determine which to use? 2.How do you create an array of strings? 3.How do you change the text content of a tag? 4.How do you find the element with attribute "id='scroll'"? 5.What are three examples where arrays are useful? 6.How does the setTimeout() function work? 7.What is a scrolling message? How do you create such a message using JavaScript and HTML? 8.How do you use a loop to cause an image to move in a browser window?