JavaScript & DHTML INE2720 Web Application Software Development Essential Materials.

Slides:



Advertisements
Similar presentations
17 HTML, Scripting, and Interactivity Section 17.1 Add an audio file using HTML Create a form using HTML Add text boxes using HTML Add radio buttons and.
Advertisements

WEB DESIGN TABLES, PAGE LAYOUT AND FORMS. Page Layout Page Layout is an important part of web design Why do you think your page layout is important?
The Web Warrior Guide to Web Design Technologies
Chapter 16 Dynamic HTML and Animation The Web Warrior Guide to Web Design Technologies.
Create slices and hotspots Create links in Web pages Create rollovers from slices Create basic animation Add tweening symbol instances to create animation.
Javascript Document Object Model. How to use JavaScript  JavaScript can be embedded into your html pages in a couple of ways  in elements in both and.
Macromedia Dreamweaver 4 Advanced Level Course. Add Rollovers Rollovers or mouseovers are possibly the most popular effects used in designing Web pages.
JavaScript 101 Lesson 5: Introduction to Events. Lesson Topics Event driven programming Events and event handlers The onClick event handler for hyperlinks.
JavaScript, Third Edition
Chapter 9 Introduction to the Document Object Model (DOM) JavaScript, Third Edition.
Chapter 7: Dynamic HTML and Animation JavaScript - Introductory.
Chapter 11 Adding Media and Interactivity. Flash is a software program that allows you to create low-bandwidth, high-quality animations and interactive.
Getting Started with Dreamweaver
DHTML - Introduction Introduction to DHTML, the DOM, JS review.
Chapter 4 Dreamweaver: Part II The Web Warrior Guide to Web Design Technologies.
DHTML. What is DHTML?  DHTML is the combination of several built-in browser features in fourth generation browsers that enable a web page to be more.
INTRODUCTION TO DHTML. TOPICS TO BE DISCUSSED……….  Introduction Introduction  UsesUses  ComponentsComponents  Difference between HTML and DHTMLDifference.
Web Design, 3 rd Edition 4 Planning a Successful Web Site: Part 2.
Copyright © Texas Education Agency, All rights reserved. 1 Web Technologies Website Development with Dreamweaver.
Chapter 3 Dreamweaver: Part I The Web Warrior Guide to Web Design Technologies.
Tutorial 4: Using CSS for Page Layout. 2 Objectives Session 4.1 Explore CSS layout Compare types of floating layouts Examine code for CSS layouts View.
University of Sunderland CDM105 Session 7 Advanced Dreamweaver More functions to help create better web pages Page Layout, Cascading Style Sheets, behaviours,
© Cheltenham Computer Training 2001 Macromedia Dreamweaver 4 - Slide No 1 Macromedia Dreamweaver 4 Advanced Level Course.
INTRODUCTION TO FRONTPAGE. TOPICS TO BE DISCUSSED……….  Introduction Introduction  Features Features  Starting Front Page Starting Front Page  Components.
McGraw-Hill/Irwin © 2004 by The McGraw-Hill Companies, Inc. All rights reserved. Dynamic Action with Macromedia Dreamweaver MX Barry Sosinsky Valda Hilley.
Web Technologies Website Development Trade & Industrial Education
Advanced Level Course. Site Extras Site Extras consist of four categories: Stationeries Site Trash Designs Components.
Lesson 19. JavaScript errors Since JavaScript is an interpreted language, syntax errors will usually cause the script to fail. Both browsers will provide.
1 SEG3120 Analysis and Design for User Interfaces Flash Anis Zarrad Parallel Simulations and Distributed Systems (PARADISE) Research Laboratory SITE, University.
ECA 225 Applied Interactive Programming1 ECA 225 Applied Online Programming DOM.
Website Development with Dreamweaver
Domain 3 Understanding the Adobe Dreamweaver CS5 Interface.
Lesson13. JavaScript JavaScript is an interpreted language, designed to function within a web browser. It can also be used on the server.
JavaScript, Fourth Edition
Tutorial 8 Programming with ActionScript 3.0. XP Objectives Review the basics of ActionScript programming Compare ActionScript 2.0 and ActionScript 3.0.
Introduction to JavaScript 41 Introduction to Programming the WWW I CMSC Winter 2004 Lecture 17.
Presented by Graduate Design Group 2 Meredith, Jennifer, Cammay and Diane.
XP Tutorial 12 New Perspectives on HTML, XHTML, and DHTML, Comprehensive 1 Working with Special Effects Creating Rollovers, Menus, Filters, and Transitions.
Copyright 2007, Information Builders. Slide 1 Understanding Basic HTML Amanda Regan Technical Director June, 2008.
DHTML - Introduction Chapter Introduction to DHTML, the DOM, JS review.
Interactive Client-Side Technologies MMIS 656 Web Design Technologies Acknowledgements: Estrella, S. (2003). The Web Wizard’s Guide to DHTML and CSS.
Chapter 5 Quick Links Slide 2 Performance Objectives Understanding Framesets and Frames Creating Framesets and Frames Selecting Framesets and Frames Using.
 2004 Prentice Hall, Inc. All rights reserved. Chapter 13 - Dynamic HTML: Object Model and Collections Outline 13.1 Introduction 13.2 Object Referencing.
Ch. 8 Web Page Design – Animation and Behaviors Mr. Ursone.
Chapter 14 Events, Scripts and Interactivity. Key Points ► Actions, usually implemented by scripts are executed in response to events, such as mouse clicks.
Cs332a_chapt10.ppt CS332A Advanced HTML Programming DHTML Dynamic Hypertext Markup Language A term describing a series of technologies Not a stand-a-lone.
1 A Basic Introduction to Flash. Outline What is a flash? Macromedia Flash MX 2004 Flash concepts Flash Demos Conclusion Additional help 2.
Introduction to HTML. _______________________________________________________________________________________________________________ 2 Outline Key issues.
Copyright © Terry Felke-Morris WEB DEVELOPMENT & DESIGN FOUNDATIONS WITH HTML5 7 TH EDITION Chapter 14 Key Concepts 1 Copyright © Terry Felke-Morris.
Chapter 11 Adding Media and Interactivity. Chapter 11 Lessons Introduction 1.Add and modify Flash objects 2.Add rollover images 3.Add behaviors 4.Add.
Positioning Objects with CSS and Tables
XP Tutorial 8 Adding Interactivity with ActionScript.
Project 7: Exploring DHTML Essentials for Design JavaScript Level Two Michael Brooks.
Chapter 10 Dynamic HTML (DHTML) JavaScript, Third Edition.
Javascript Basic Concepts Presentation By: Er. Sunny Chanday Lecturer CSE/IT RBIENT.
XP New Perspectives on Macromedia Dreamweaver MX 2004 Tutorial 5 1 Adding Shared Site Elements.
XP New Perspectives on Macromedia Dreamweaver MX 2004 Tutorial 6 1 Creating Dynamic Pages.
HTML Introduction HTML Editors HTML Basic HTML Elements HTML Attributes HTML Headings HTML Paragraphs HTML Formatting HTML Links HTML Head HTML CSS HTML.
COM621: Advanced Interactive Web Development Lecture 6 – JavaScript (cont.)
Copyright © Terry Felke-Morris Web Development & Design Foundations with HTML5 8 th Edition CHAPTER 14 KEY CONCEPTS 1 Copyright.
CIS 375—Web App Dev II DHTML. 2 Introduction to DHTML _________ HTML is “a term used by some vendors to describe the combination of HTML, style sheets.
DHTML.
Using DHTML to Enhance Web Pages
Web Development & Design Foundations with HTML5 7th Edition
DHTML Javascript Internet Technology.
DHTML Javascript Internet Technology.
Tutorial 6 Creating Dynamic Pages
Working with Special Effects
Introduction to DHTML, the DOM, JS review
Presentation transcript:

JavaScript & DHTML INE2720 Web Application Software Development Essential Materials

INE2720 – Web Application Software Development All copyrights reserved by C.C. Cheung Outline – Part D Introducing DHTML Introducing DHTML –Styles and Layers –Dynamic Positioning –Moving objects in 3D –Internet Explorer Filters Using DHTML and CSS Tools Using DHTML and CSS Tools Cool JavaScript Sites Cool JavaScript Sites JavaScript and DHTML Reference JavaScript and DHTML Reference Summary Summary

INE2720 – Web Application Software Development All copyrights reserved by C.C. Cheung Dynamic HTML Everyone is a Web Designer. Everyone is a Web Designer. –Learning DHTML, CSS and JavaScript is your next step into the web design world. “ DHTML ” is a term used by some vendors to describe the combination of HTML, style sheets and scripts that allows documents to be animated. “ DHTML ” is a term used by some vendors to describe the combination of HTML, style sheets and scripts that allows documents to be animated. Web pages can be made to respond to users ’ actions. Web pages can be made to respond to users ’ actions. Problem: How to achieve “ Dynamic ” ? Problem: How to achieve “ Dynamic ” ?

INE2720 – Web Application Software Development All copyrights reserved by C.C. Cheung DHTML advantages / disadvantages Supported by most browsers Supported by most browsers Small file sizes (faster than Flash) Small file sizes (faster than Flash) No plug-ins required No plug-ins required Easy to learn (learn HTML, JavaScript) Easy to learn (learn HTML, JavaScript) Faster web experience (change the page content without load new pages) Faster web experience (change the page content without load new pages) Browser and OS incompatibilities Browser and OS incompatibilities –The implementation of CSS, DOM varies from browser to browser

INE2720 – Web Application Software Development All copyrights reserved by C.C. Cheung What makes a web site dynamic? Interactivity – adapt and react to the visitor ’ s actions as quick as possible. Interactivity – adapt and react to the visitor ’ s actions as quick as possible. Synchronicity – bring together relevant information from a variety of sources. Synchronicity – bring together relevant information from a variety of sources. Flexibility – give the visitor different ways to find information in the site. Flexibility – give the visitor different ways to find information in the site. Adaptability – adjusts to cater to individual visitor ’ s needs. Adaptability – adjusts to cater to individual visitor ’ s needs. Activity – uses motion and sound to draw user ’ s attention to changes on the site. Activity – uses motion and sound to draw user ’ s attention to changes on the site.

INE2720 – Web Application Software Development All copyrights reserved by C.C. Cheung The Role of each component in DHTML With CSS, we can change the style of any HTML elements. With CSS, we can change the style of any HTML elements. With DOM, we can have a map on every elements in the HTML page. With DOM, we can have a map on every elements in the HTML page. With JavaScript, we can access and have operations on the elements in the DOM tree. With JavaScript, we can access and have operations on the elements in the DOM tree. With event handler, we can execute the predefined scripts at any time. With event handler, we can execute the predefined scripts at any time.

INE2720 – Web Application Software Development All copyrights reserved by C.C. Cheung Cross-Browser DHTML Netscape 4.x Cross-Browser DHTML Internet Explorer 4.x JavaScript Style Sheets (JSS) JavaScript Style Sheets (JSS) Netscape Layers (positioning, visibility) Netscape Layers (positioning, visibility) CSS1, CSS2, CSS-Positioning CSS1, CSS2, CSS-Positioning JavaScript JavaScript DOM DOM Visual Filters allow you to apply visual effects to text or graphics Visual Filters allow you to apply visual effects to text or graphics Data Binding Data Binding

INE2720 – Web Application Software Development All copyrights reserved by C.C. Cheung Open a new browser window Pop-up windows are useful for navigation controls, advertisements, supplementary contents. Pop-up windows are useful for navigation controls, advertisements, supplementary contents. You can open a window, close the window, or toggle the window. You can open a window, close the window, or toggle the window.

INE2720 – Web Application Software Development All copyrights reserved by C.C. Cheung Dynamic Technique: Change CSS Styles You can change or add to any CSS property defined for any object on the screen. You can change or add to any CSS property defined for any object on the screen. onMouseOver()

INE2720 – Web Application Software Development All copyrights reserved by C.C. Cheung Change Background Color <html><head> function bgChange(bg) {document.body.style.background=bg; } </script></head> Mouse over these table cells, and the background color will change Mouse over these table cells, and the background color will change <td onmouseover="bgChange('red')" <td onmouseover="bgChange('red')" onmouseout="bgChange('transparent')" bgcolor="red"> <td onmouseover="bgChange('blue')" <td onmouseover="bgChange('blue')" onmouseout="bgChange('transparent')" bgcolor="blue"> <td onmouseover="bgChange('green')" <td onmouseover="bgChange('green')" onmouseout="bgChange('transparent') ” bgcolor="green"> </tr></table></body></html>

INE2720 – Web Application Software Development All copyrights reserved by C.C. Cheung CSS Properties Reference: Reference:

INE2720 – Web Application Software Development All copyrights reserved by C.C. Cheung Dynamic Positioning It means the HTML elements can be positioned by using JavaScript. It means the HTML elements can be positioned by using JavaScript. The element is moved by manipulating any of the “ top ”, “ left ”, “ right ” and “ bottom ” CSS properties. The element is moved by manipulating any of the “ top ”, “ left ”, “ right ” and “ bottom ” CSS properties. The more table you use, the slower your page displays. The more table you use, the slower your page displays. Positioning elements with CSS is more accurate than tables and the results are displayed much faster. Positioning elements with CSS is more accurate than tables and the results are displayed much faster.

INE2720 – Web Application Software Development All copyrights reserved by C.C. Cheung Moving Objects from Point to Point Using CSS, you can change the position of an object on the screen. Using CSS, you can change the position of an object on the screen.

INE2720 – Web Application Software Development All copyrights reserved by C.C. Cheung Moving Objects in 3-D By specifying the z-index, we can put the objects in 3-D manner. By specifying the z-index, we can put the objects in 3-D manner.

INE2720 – Web Application Software Development All copyrights reserved by C.C. Cheung Moving the browser window You can set an initial position of multiple windows. You can set an initial position of multiple windows.

INE2720 – Web Application Software Development All copyrights reserved by C.C. Cheung IE DHTML Visual Controls The blurOn() Filter causes the image to blur on the screen. The blurOn() Filter causes the image to blur on the screen.

INE2720 – Web Application Software Development All copyrights reserved by C.C. Cheung IE Transition Filters Produce transitions between web pages. Produce transitions between web pages.Transition Reference # Box In 0 Box Out 1 Circle out 3 Wipe up 4 Wipe down 5 Wipe right 6 Wipe left 7 Random Dissolve 12 Random23

INE2720 – Web Application Software Development All copyrights reserved by C.C. Cheung Adding last modified Date <html><head> Enter the title of your HTML document here Enter the title of your HTML document here </head><body> document.write(“Page last modified: “ + document.lastModified) </script></body></html>

INE2720 – Web Application Software Development All copyrights reserved by C.C. Cheung Creating a Sliding Menu Allow visitors to pull out menus or put them away. Allow visitors to pull out menus or put them away.

INE2720 – Web Application Software Development All copyrights reserved by C.C. Cheung Follow the Mouse Pointer The mouse pointer is part of the user interface that gives designer controls. The mouse pointer is part of the user interface that gives designer controls.

INE2720 – Web Application Software Development All copyrights reserved by C.C. Cheung Application: Using JavaScript to Make Pages Dynamic Modifying Images Dynamically Modifying Images Dynamically –The document.images property contains an array of Image objects corresponding to each IMG element in the current document –To display a new image, simply set the SRC property of an existing image to a string representing a different image file

INE2720 – Web Application Software Development All copyrights reserved by C.C. Cheung Modifying Images, Example The following function changes the first image in a document The following function changes the first image in a document function changeImage() { function changeImage() { document.images[0].src = "images/new-image.gif"; document.images[0].src = "images/new-image.gif"; } Referring to images by name is easier: Referring to images by name is easier: <img src="cool-image.jpg" name="cool" <img src="cool-image.jpg" name="cool" width=75 height=25> width=75 height=25> function improveImage() { function improveImage() { document.images["cool"].src = "way-cool.jpg"; document.images["cool"].src = "way-cool.jpg"; }

INE2720 – Web Application Software Development All copyrights reserved by C.C. Cheung Modifying Images: A Clickable Image Button, Example <!-- imageFiles = new Array("images/Button1-Up.gif", "images/Button1-Down.gif", "images/Button1-Down.gif", "images/Button2-Up.gif", "images/Button2-Up.gif", "images/Button2-Down.gif"); "images/Button2-Down.gif"); imageObjects = new Array(imageFiles.length); for(var i=0; i<imageFiles.length; i++) { imageObjects[i] = new Image(150, 25); imageObjects[i] = new Image(150, 25); imageObjects[i].src = imageFiles[i]; imageObjects[i].src = imageFiles[i];} function setImage(name, image) { document.images[name].src = image; document.images[name].src = image;}

INE2720 – Web Application Software Development All copyrights reserved by C.C. Cheung Modifying Images: A Clickable Image Button, Example function clickButton(name, grayImage) { var origImage = document.images[name].src; var origImage = document.images[name].src; setImage(name, grayImage); setImage(name, grayImage); var resetString = var resetString = "setImage('" + name + "', '" + origImage + "')"; "setImage('" + name + "', '" + origImage + "')"; setTimeout(resetString, 100); setTimeout(resetString, 100);} // --> // --> </head>... <a href="location1.html" onMouseOver="clickButton('Button1', 'images/Button1-Down.gif')"> onMouseOver="clickButton('Button1', 'images/Button1-Down.gif')"> <img src="images/Button1-Up.gif" name="Button1" width=150 height=25> width=150 height=25> <a href="location2.html" onMouseOver="clickButton('Button2', 'images/Button2-Down.gif')"> onMouseOver="clickButton('Button2', 'images/Button2-Down.gif')"> <img src="images/Button2-Up.gif" name="Button2" width=150 height=25> width=150 height=25>...

INE2720 – Web Application Software Development All copyrights reserved by C.C. Cheung Highlighting Images Under the Mouse, Example <html> High Peaks Navigation Bar High Peaks Navigation Bar <!— // Given "Foo", returns "images/Foo.gif". function regularImageFile(imageName) { return("images/" + imageName + ".gif"); return("images/" + imageName + ".gif");} // Given "Bar", returns "images/Bar-Negative.gif". function negativeImageFile(imageName) { return("images/" + imageName + "-Negative.gif"); return("images/" + imageName + "-Negative.gif");}

INE2720 – Web Application Software Development All copyrights reserved by C.C. Cheung Highlighting Images Under the Mouse, Example, cont. // Cache image at specified index. E.g., given index 0, // take imageNames[0] to get "Home". Then preload // images/Home.gif and images/Home-Negative.gif. function cacheImages(index) { regularImageObjects[index] = new Image(150, 25); regularImageObjects[index] = new Image(150, 25); regularImageObjects[index].src = regularImageFile(imageNames[index]); regularImageObjects[index].src = regularImageFile(imageNames[index]); negativeImageObjects[index] = new Image(150, 25); negativeImageObjects[index] = new Image(150, 25); negativeImageObjects[index].src = negativeImageFile(imageNames[index]); negativeImageObjects[index].src = negativeImageFile(imageNames[index]);} imageNames = new Array("Home", "Tibet", "Nepal", "Austria", "Switzerland"); regularImageObjects = new Array(imageNames.length); negativeImageObjects = new Array(imageNames.length); // Put images in cache for fast highlighting. for(var i=0; i<imageNames.length; i++) { cacheImages(i); cacheImages(i);}

INE2720 – Web Application Software Development All copyrights reserved by C.C. Cheung Highlighting Images Under the Mouse, Example, cont.... function highlight(imageName) { document.images[imageName].src = negativeImageFile(imageName); document.images[imageName].src = negativeImageFile(imageName);} function unHighlight(imageName) { document.images[imageName].src = regularImageFile(imageName); document.images[imageName].src = regularImageFile(imageName);} // --> </script></head><body><table> <a href="Tibet.html" target="Main" onMouseOver="highlight('Tibet')" onMouseOut="unHighlight('Tibet')"> onMouseOver="highlight('Tibet')" onMouseOut="unHighlight('Tibet')">...

INE2720 – Web Application Software Development All copyrights reserved by C.C. Cheung Highlighting Images Under the Mouse, Result

INE2720 – Web Application Software Development All copyrights reserved by C.C. Cheung Application: Using JavaScript to Interact with Frames Idea Idea –The default Window object contains a frames property holding an array of frames (other Window objects) contained by the current window or frame. It also has parent and top properties referring to the directly enclosing frame or window and the top-level window, respectively. It also has parent and top properties referring to the directly enclosing frame or window and the top-level window, respectively. All of the properties of Window can be applied to any of these entries. All of the properties of Window can be applied to any of these entries.

INE2720 – Web Application Software Development All copyrights reserved by C.C. Cheung Displaying a URL in a Particular Frame, Example <HTML><HEAD> Show a URL Show a URL </HEAD> </FRAMESET></HTML>

INE2720 – Web Application Software Development All copyrights reserved by C.C. Cheung Displaying a URL in a Particular Frame, Example, cont. Choose a URL Choose a URL function showURL() { var url = document.urlForm.urlField.value; var url = document.urlForm.urlField.value; // or parent.frames["displayFrame"].location = url; // or parent.frames["displayFrame"].location = url; parent.displayFrame.location = url; parent.displayFrame.location = url;} function preloadUrl() { if (navigator.appName == "Netscape") { if (navigator.appName == "Netscape") { document.urlForm.urlField.value = " document.urlForm.urlField.value = " } else { } else { document.urlForm.urlField.value = " document.urlForm.urlField.value = " }} Choose a URL Choose a URL URL: URL: </form></center></body></html>

INE2720 – Web Application Software Development All copyrights reserved by C.C. Cheung Displaying a URL in a Particular Frame, Result

INE2720 – Web Application Software Development All copyrights reserved by C.C. Cheung Giving a Frame the Input Focus, Example If JavaScript is manipulating the frames, the fix is easy: just add a call to focus in showUrl: If JavaScript is manipulating the frames, the fix is easy: just add a call to focus in showUrl: function showURL() { var url = document.urlForm.urlField.value; var url = document.urlForm.urlField.value; parent.displayFrame.location = url; // Give frame the input focus parent.displayFrame.focus();} Fixing the problem in regular HTML documents is a bit more tedious Fixing the problem in regular HTML documents is a bit more tedious –Requires adding onClick handlers that call focus to each and every occurrence of A and AREA that includes a TARGET, and a similar onSubmit handler to each FORM that uses TARGET

INE2720 – Web Application Software Development All copyrights reserved by C.C. Cheung Using DHTML and CSS Tools Adobe GoLive Adobe GoLive –A complete HTML creation package –An easy-to-use environment for JavaScript editing, CSS and DHTML. Macromedia Dreamweaver Macromedia Dreamweaver –Includes a bevy of other tools such as FTP, site management. –Allows you to add Flash objects.

INE2720 – Web Application Software Development All copyrights reserved by C.C. Cheung Cool JavaScript Sites –Provides DHTML script examples –JavaScript examples and get the source –JavaScript examples –JavaScript examples from Netscape –JavaScript Workshop –An entertaining place for learning web design

INE2720 – Web Application Software Development All copyrights reserved by C.C. Cheung JavaScript References –Resources of all standards –A well-structured website –HTML help by the web design group –Includes coding, design tips, editorials –In-depth articles on DHTML, CSS, … –FAQs for DHTML, CSS, JavaScript, …

INE2720 – Web Application Software Development All copyrights reserved by C.C. Cheung Summary Learnt the basics of JavaScript: Learnt the basics of JavaScript: –Variable, Data Types, Flow Control, Loops –Function, Event, Objects –Exception and Error Handling JavaScript permits you to: JavaScript permits you to: –Make pages more dynamic –Validate HTML form input –Manipulate cookies –Control frames –Combine with CSS, DOM to build DHTML pages

INE2720 – Web Application Software Development All copyrights reserved by C.C. Cheung References Web Warrior Series - JavaScript Web Warrior Series - JavaScript JavaScript 1.5 by example JavaScript 1.5 by example SAMS – JavaScript SAMS – JavaScript JavaScript Goodies JavaScript Goodies DHTML and CSS for the WWW DHTML and CSS for the WWW The End. The End. Thank you for patience! Thank you for patience!