What we learned in last lesson How to add JavaScript to your HTML pages How to use dialog boxes and variables to store and utilize user input How to write.

Slides:



Advertisements
Similar presentations
Chapter 7 JavaScript: Introduction to Scripting. Outline Simple Programs Objects and Variables Obtaining User Input with prompt Dialogs – –Dynamic Welcome.
Advertisements

Tutorial 5 Windows and Frames Section A - Working with Windows.
Copyright ©2005 Department of Computer & Information Science Advanced DHTML & DOM: Working with the Window Object.
Sue Wills July Objects The JavaScript language is completely centered around objects, and because of this, it is known as an Object Oriented Programming.
KompoZer. This is what KompoZer will look like with a blank document open. As you can see, there are a lot of icons for beginning users. But don't be.
The Web Warrior Guide to Web Design Technologies
JavaScript DOM and CSS What we should learn in this lesson –What is DOM-The JavaScript Document Object Module, its architectures, methods.. –Dynamic Website.
JavaScript (Part 2) CS 183 4/13/2010. JavaScript (Part 2) Will cover: ◦ For.. In ◦ Events ◦ Try.. Catch, Throw ◦ Objects.
Web-based Application Development Lecture 9 February 7, 2006 Anita Raja.
Information Technology Center Hany Abdelwahab Computer Specialist.
CIS101 Introduction to Computing Week 11. Agenda Your questions Copy and Paste Assignment Practice Test JavaScript: Functions and Selection Lesson 06,
JavaScript 101 Lesson 5: Introduction to Events. Lesson Topics Event driven programming Events and event handlers The onClick event handler for hyperlinks.
3.2 Presentation Software End Show Creating slide shows including audio,video and digital images End Show.
Lesson15. JavaScript Objects Objects encapsulate data (properties) and behavior(methods); the properties and the methods of an object are tied together.
Creating a Web Page HTML, FrontPage, Word, Composer.
Web Programming Material From Greenlaw/Hepp, In-line/On-line: Fundamentals of the Internet and the World Wide Web 1 Introduction The JavaScript Programming.
Javascript and the Web Whys and Hows of Javascript.
4.1 JavaScript Introduction
Chapter 3 Dreamweaver: Part I The Web Warrior Guide to Web Design Technologies.
Links in HTML. Hyperlinks or links Millions of linked web pages make up the World Wide Web Used to connect a web page to another web page on the same.
Applied Software for Internet Engineers by Dr Zhanfang ZHAO Room: T409 Tel: Study hours: 150hrs, 24 hrs lecture/Tutorials,
SYST Web Technologies SYST Web Technologies Lesson 6 – Intro to JavaScript.
The Document Object Model. Goals Understand how a JavaScript can communicate with the web page in which it “lives.” Understand how to use dot notation.
WEEK 3 AND 4 USING CLIENT-SIDE SCRIPTS TO ENHANCE WEB APPLICATIONS.
UFCEWT-20-3 Advanced Topics in Web Development Lecture 4 : JavaScript, Browsers & the HTML DOM-API.
Arrays – What is it? – Creation – Changing the contents Functions – What is it? – Syntax – How they work – Anonymous functions A quick lesson in Objects.
Adding User Interactivity – Lesson 51 Adding User Interactivity Lesson 5.
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.
What is Java Script? An extension to HTML. An extension to HTML. Allows authors to incorporate some functionality in their web pages. (without using CGI.
Domain 3 Understanding the Adobe Dreamweaver CS5 Interface.
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.
1 JavaScript in Context. Server-Side Programming.
Using Client-Side Scripts to Enhance Web Applications 1.
Extending HTML CPSC 120 Principles of Computer Science April 9, 2012.
Introduction to JavaScript 41 Introduction to Programming the WWW I CMSC Winter 2004 Lecture 17.
HTML Concepts and Techniques Fifth Edition Chapter 6 Using Frames in a Web Site.
Chapter 5: Windows and Frames
XP Tutorial 6 New Perspectives on JavaScript, Comprehensive1 Working with Windows and Frames Enhancing a Web Site with Interactive Windows.
JavaScript - A Web Script Language Fred Durao
Overview of Form and Javascript fundamentals. Brief matching exercise 1. This is the software that allows a user to access and view HTML documents 2.
JavaScript Scripting language What is Scripting ? A scripting language, script language, or extension language is a programming language.
Sahar Mosleh California State University San MarcosPage 1 JavaScript Basic.
Chapter 2: Variables, Functions, Objects, and Events JavaScript - Introductory.
JavaScript, Fourth Edition Chapter 4 Manipulating the Browser Object Model.
Visual Basic for Application - Microsoft Access 2003 Programming applications using Objects.
1 Chapter 3 – JavaScript Outline Introduction Flowcharts Control Structures if Selection Structure if/else Selection Structure while Repetition Structure.
WDMD 170 – UW Stevens Point 1 WDMD 170 Internet Languages eLesson: Variables, Functions and Events (NON-Audio version) © Dr. David C. Gibbs WDMD.
Chapter 5 Introduction To Form Builder. Lesson A Objectives  Display Forms Builder forms in a Web browser  Use a data block form to view, insert, update,
Functions.  Assignment #2 is now due on Wednesday, Nov 25 th  (No Quiz)  Go over the midterm  Backtrack and re-cover the question about tracing the.
Project 5: Using Pop-Up Windows Essentials for Design JavaScript Level One Michael Brooks.
CISW CRC - Fishman 2014 / 2015 PRESENTATION 4b: CISW 400 (Online) – Client-side Scripting for the Internet Cosumnes River College Fishman – 2015.
Easy WP Guide V2.6 for WordPress 3.8. easywpguide.com Adding Tags within your Post Adding Tags whilst editing your Post, will automatically assign those.
Working with the Window Object JavaScript considers the browser window an object, which it calls the window object.
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.
Introduction to JavaScript MIS 3502, Spring 2016 Jeremy Shafer Department of MIS Fox School of Business Temple University 2/2/2016.
1 Lesson 6 Introducing JavaScript HTML and JavaScript BASICS, 4 th Edition.
JavaScript 101 Lesson 6: Introduction to Functions.
JavaScript Events. Understanding Events Events add interactivity between the web page and the user Events add interactivity between the web page and the.
Microsoft Visual C# 2010 Fourth Edition Chapter 3 Using GUI Objects and the Visual Studio IDE.
COM621: Advanced Interactive Web Development Lecture 6 – JavaScript (cont.)
Introduction to.
Applied Component I Unit II Introduction of java-script
With Microsoft FrontPage 2000
Learning the Basics – Lesson 1
A second look at JavaScript
Events Comp 205 Fall 2017.
Tutorial 6 Creating Dynamic Pages
JavaScript is a scripting language designed for Web pages by Netscape.
Web Programming and Design
Presentation transcript:

What we learned in last lesson How to add JavaScript to your HTML pages How to use dialog boxes and variables to store and utilize user input How to write HTML to a Web page using JavaScript How to let JavaScript make decisions using if- then statements How to make your Web pages react to users' actions using link events How to do a basic image swap

What we should learn in this lesson What is DOM-The JavaScript Document Object Module, its architectures, methods.. How to transfer information between different Windows. More JavaScript Syntax.

DOM-The JavaScript Document Object Module Why the following codes works? – document.the_image.src=‘ ~zhaoza/sun.gif '; –document.writeln(“ test ”); DOM is the way JavaScript describes Web pages, and it lies at the heart of all JavaScript programming

Window Manipulation in JavaScript Open a window using HTML: – Open new window Open a widow using JavaScript Window.open(“URL”,”name”,”feature”) –This statement opens a window with the URL that you list as the first parameter in the method call. Above it's called "URL," but in an actual call you'd write " or something similar. –The second parameter of the method call is the window's name. This is just like the name we saw above. If you open a window and there's already a window open with the same name, the URL in your open statement will be sent to that open window. –The third parameter, features, is a list of the different components a window can have. It's an optional parameter

examples of using JavaScript to open windows Here's a window named javascript_1 Here's a window named javascript_2 Here's another HTML page going into javascript_1

Windows Features menubar This is the row of functions that appears on most software applications. Normally it includes File, Edit, and a few other items. status This is the message bar at the bottom of your window. When you move your mouse over an HTML link, the URL appears in the status bar. You may have seen pages that use scrollbars This allows scrollbars to appear when necessary. resizable If resizable is listed, the window can be resized. width The width of the window in pixels. height The height of the window in pixels. toolbar The browser toolbar, which contains the Back and Forward buttons, the Stop button, and the Home button, among others. location The text area of a browser into which you can type URLs. directories The directories that Netscape browsers have called "What's new," "What's cool," and so on.

Some examples for windows features window.open ("some_url", "window_name", "location,menubar"); Above statement will get a window with just the location box (the place in your browser where you type in a URL) and a menu bar (File, Edit, etc.) window.open("some_url","window_name", "location,height=100,width=100"); This will open a window that is 100 pixels high and 100 pixels wide and has no features other than a location field. Notice again that there are no spaces in the string If you'd like to open a window that has almost all the features, you can specify which features you don't want by setting those features equal to no. For example: window.open("some_url", "window_name", "location=no,status=no"); This will open a window that has all the features except the location field and the status bar.

The JavaScript Document Object Model JavaScript is an Object-oriented programming language. The main idea of OOP is that information is organized in terms of objects. JavaScript is wonderful because it comes with a built-in library of objects. For example, a window is an object. Object properties Objects have properties that describe them. For example the windows object has properties such as its name, the words in its status bar, the URL of the document inside the window, and the window’s document. Objects methods In addition to properties, objects also have methods. Methods are the actions an object knows how to take. For example, Windows know how to open other Windows: window.open("URL,""name,""features"). This tells JavaScript to use the open method of the Window object to open a new window. For the windows object, we already learn its methods such as: open(), alert(), prompt(), confirm() etc. Here introduces two more, focus and blur, The focus method moves a window that's behind other windows to the front. The blur method does the reverse — it moves a window behind other windows.

One neat thing about objects is that the properties of an object can be objects too. For example, windows have a property called document that refers to the actual HTML document in the window. This document property is itself an object that has properties and methods of its own. We saw an example of this when we talked about image swapping. Go back to the last lesson, we learned that you can do an image swap like this: change That long string, window.document.the_image.src='button_d.gif', translates into: "Find the document property of the window, find the_image property of the document, find the src property of the_image, and set it to button_d.gif.“ It may seem like a lot of detail to keep track of. The JavaScript Document Object Model describes a small hierarchy of objects. Here it is:

JavaScript’s objects The top box of the diagram represents your browser window. Following the line from that box down, you'll see it connects to seven more boxes. These are the properties of the browser window. The sixth box here, "document," represents the contents of your window. If you follow the little line leading out of the document box, you'll see it connects to six more boxes. These are the properties of the document object.

Communicating between Windows Getting and using a window reference <!-- hide me // open a new window, In order to communicate with a window using // JavaScript, you need a reference to that window. var new_window = window.open("hello.html","html_name","width=200,height=200"); //This opens a little window and assigns the variable new_window //to refer to it. And then blur the new window new_window.blur(); // show me --> A new window has been opened and moved to the background. Bring it forward Put it backward

Messing with the DOM in other Windows Image Remote <!-- hide me //opens a new window and assigns the variable display_window to that window var display_window = window.open("slide_show_main.html","display_window"); window.focus(); // stop hiding -->

slide_show_main.html Remote Image Swapping

Getting Framed In JavaScript, Frames are treated just like windows Main.html: Using Frames with JavaScript Frames_example_controls.html: Frames Example Controls <a href="#" onClick="top.target_frame.document.writeln('Monkey do! ');">Monkey see

Some other JavaScript Syntax Loops –While loops: while (some test is true) { do the stuff inside the curly braces } –For loops: for (initial value; test; increment) { do this stuff; } Arrays- Arrays are lists. –An example to create an array of colors: var colors = new Array("red","blue","green"); good thing about arrays is that elements of an array can be accessed by number. The first element is number 0 and can be accessed like this: var the_element = colors[0]; After you execute this line of JavaScript, the variable the_element will hold the string "red."

An example for Loops and Arrays(slide show) URL Slideshow <!-- hide me var url_names = new Array("hits.org","awaken.org","bianca.com"); var a_url; for (loop = 0; loop < url_names.length; loop++) { // make the name of a url, for example a_url = " + url_names[loop]; // open a window var new_window=open(a_url,"new_window","width=300,height=300"); // wait for the click alert("Hit OK for the next site"); } // show me -->

Functions(Timer.html) Function with No Parameters <!-- hide me function announceTime() { //get the date, the hour, minutes, and seconds var the_date = new Date(); var the_hour = the_date.getHours(); var the_minute = the_date.getMinutes(); var the_second = the_date.getSeconds(); //put together the string and alert with it var the_time = the_hour + ":" + the_minute + ":" + the_second; alert("The time is now: " + the_time); } // show me --> time!