Working with background, images and date object Basharat Mahmood, Department of Computer Science, CIIT, Islamabad, Pakistan 1.

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

1 CS101 Introduction to Computing Lecture 41 Images & Animation (Web Development Lecture 14)
JavaScript Part 6. Calling JavaScript functions on an event JavaScript doesn’t have a main function like other programming languages but we can imitate.
End User Computing An Introduction to CSS Sujana Jyothi Research Lab1, Callan Building, Department of Computer Science
Outline IS400: Development of Business Applications on the Internet Fall 2004 Instructor: Dr. Boris Jukic JavaScript: Introduction to Scripting.
1 HCI 201 JavaScript - Part 1. 2 Static web pages l Static pages: what we have worked with so far l HTML tags tell the browser what to do with the content.
Computer Science 1611 Internet & Web Creating Webpages with Style Hypertext and the HTML Markup Language (continued)
Database Connectivity in PHP Basharat Mahmood, Department of Computer Science,CIIT,Islamabad, Pakistan. 1.
Chapter 9 Introduction to the Document Object Model (DOM) JavaScript, Third Edition.
File uploading in PHP Basharat Mahmood, Department of Computer Science,CIIT,Islamabad, Pakistan. 1.
JavaScript Objects Objects – JavaScript is an object-based language Has built-in objects we will use – You can create your own objects We concentrating.
Tables in HTML Basharat Mahmood, Department of Computer Science,CIIT,Islamabad, Pakistan. 1.
CST JavaScript Validating Form Data with JavaScript.
Web Programming Material From Greenlaw/Hepp, In-line/On-line: Fundamentals of the Internet and the World Wide Web 1 Introduction The JavaScript Programming.
Deleting and Updating Records in MySQL using PHP Basharat Mahmood, Department of Computer Science,CIIT,Islamabad, Pakistan. 1.
Using Object-Oriented JavaScript CST 200- JavaScript 4 –
The Web Wizard’s Guide To JavaScript Chapter 1 JavaScript Basics.
Page Layout Basharat Mahmood, Department of Computer Science, CIIT, Islamabad, Pakistan 1.
Scripting Languages.
JavaScript Lecture 6 Rachel A Ober
History, Navigator, Screen and Form Objects Basharat Mahmood, Department of Computer Science, CIIT, Islamabad, Pakistan 1.
© Copyright by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. 1 Tutorial 30 – Bookstore Application: Client Tier Introducing.
The Web Wizard’s Guide To JavaScript Chapter 6 Working with Dates and Times.
JavaScript for Client-Side Content Behavior Chapter 7.
Adding Image, audio and video files to web pages Basharat Mahmood, Department of Computer Science,CIIT,Islamabad, Pakistan. 1.
Introduction to HTML 1 Basharat Mahmood, Department of Computer Science, CIIT, Islamabad, Pakistan.
Introduction to JavaScript Basharat Mahmood, Department of Computer Science, CIIT, Islamabad, Pakistan. 1.
Extending HTML CPSC 120 Principles of Computer Science April 9, 2012.
ALBERT WAVERING BOBBY SENG. Week 5: More JavaScript  Quiz  Announcements/questions.
Introduction to Cascading Style-sheets (CSS) Basharat Mahm ood, Department of Computer Science, CIIT,Islamabad, Pakistan 1.
Lecture 9 The Basics of JavaScript Boriana Koleva Room: C54
Modeling web applications
Chapter 5 Quick Links Slide 2 Performance Objectives Understanding Framesets and Frames Creating Framesets and Frames Selecting Framesets and Frames Using.
Keeping it Neat: Functions and JavaScript Source Files Chapter 7.
Retrieving data from MySQL using PHP Basharat Mahmood, Department of Computer Science,CIIT,Islamabad, Pakistan. 1.
Modified from Moseley ’s sli desWeb Applications Development. Lecture 3 Slide 1 Lecture 3: Dynamic Web Pages – Introduction to JavaScript Instructor: Dr.
Copyright ©2005  Department of Computer & Information Science Beginning DHTML: Working with Browser Objects.
Chapter 2: Variables, Functions, Objects, and Events JavaScript - Introductory.
HTML. Adding Background Color The bgcolor attribute lets you change the background color of the Web page. Located in the body tag See common Web Page.
The Web Wizard’s Guide to HTML Chapter Three Colors, Patterns, and Inline Graphics.
HTML FORMS Basharat Mahmood, Department of Computer Science,CIIT,Islamabad,Pakistan. 1.
CSS properties Basharat Mahmood, Department of Computer Science, CIIT, Islamabad, Pakistan 1.
Lesson 16. Practical Application 1 We can take advantage of JavaScript and the DOM, to set up a form so that the first text box of a form automatically.
HTML CS 105. Page Structure HTML elements control the details of how a page gets displayed. Every HTML document has the following basic structure: … …
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.
HTML 5 Form elements Basharat Mahmood, Department of Computer Science,CIIT,Islamabad, Pakistan. 1.
HTML DOM Basharat Mahmood, Department of Computer Science, CIIT, Islamabad, Pakistan 1.
Tutorial 11 1 JavaScript Operators and Expressions.
Chapter 1 Murach's JavaScript and jQuery, C1© 2012, Mike Murach & Associates, Inc.Slide 1.
HTML Links and navigation Basharat Mahmood, Department of Computer Science,CIIT,Islamabad, Pakistan. 1.
Chapter 6 Murach's JavaScript and jQuery, C6© 2012, Mike Murach & Associates, Inc.Slide 1.
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 Tutorial. What is JavaScript JavaScript is the programming language of HTML and the Web Programming makes computers do what you want them to.
Chapter 9. An event-driven, object-based programming language that provides various types of functionality to pages. Object based: it is a language that.
Revision Webpage design HTML.   FACE  Attributes  Marquee  Define the following terms.
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.
Basic Objects. Math Object  Math.cos( x ), x in radians  Math.sqrt ( x )  Math.pow ( x, y )  Math.ceil( x )  etc.
COM621: Advanced Interactive Web Development Lecture 6 – JavaScript (cont.)
Chapter 4 Java Script – Part2. 2 Location object Properties Properties href – whole path will be displayed. ex: window.location.href ( see example 11)
CIIT-Human Computer Interaction-CSC456-Fall-2015-Mr
Lecturer (Dept. of Computer Science)
JavaScript Arrays Date
Passing variables between pages
JavaScript Forms Adding User Input.
BY: SITI NURBAYA ISMAIL FACULTY of COMPUTER and MATHEMATICAL SCIENCES
Font tag and its attributes
Pertemuan 1b
Attribute of heading, <p> and <hr> tag
Attribute of heading, <p> and <hr> tag
Attribute of heading, <p> and <hr> tag
Presentation transcript:

Working with background, images and date object Basharat Mahmood, Department of Computer Science, CIIT, Islamabad, Pakistan 1

Summary of the previous lecture Dialog boxes in JavaScript HTML DOM Retrieving HTML elements Setting HTML elements Basharat Mahmood, Department of Computer Science, CIIT, Islamabad, Pakistan 2

Outline Controlling the background dynamically Working with images Date Object Basharat Mahmood, Department of Computer Science, CIIT, Islamabad, Pakistan 3

1. Controlling the background The body tag has the following attributes – bgcolor – Background – text Basharat Mahmood, Department of Computer Science, CIIT, Islamabad, Pakistan 4

1.1 Setting the bgcolor We can access the bgcolor as – document.body.bgColor – Or – document.getElementById(“id of the body tag”).bgColor Basharat Mahmood, Department of Computer Science, CIIT, Islamabad, Pakistan 5

1.1 Setting the bgcolor Starting the function User input Setting the bgcolor Calling the function Basharat Mahmood, Department of Computer Science, CIIT, Islamabad, Pakistan 6

1.2 Setting the text color We can access the body text as – document.body.style.color – Or – document.getElementById(“id of the body tag”).style.color Basharat Mahmood, Department of Computer Science, CIIT, Islamabad, Pakistan 7

1.2 Setting the text color Set text function Setting the color Calling the functionPassing color as parameter Basharat Mahmood, Department of Computer Science, CIIT, Islamabad, Pakistan 8

1.3 Setting the background We can access the background as – document.body.background – Or – document.getElementById(“id of the body tag”).background Basharat Mahmood, Department of Computer Science, CIIT, Islamabad, Pakistan 9

1.3 Setting background Image is added Function is called Src is passed Function received the src Background is set Basharat Mahmood, Department of Computer Science, CIIT, Islamabad, Pakistan 10

2. Working with images JavaScript has a built-in object called Image The Image object allows you to create objects that represent images created using the element Properties: name, border, height, width, hspace, vspace, src Basharat Mahmood, Department of Computer Science, CIIT, Islamabad, Pakistan 11

2. Working with images… An image object can be created as – var objname= new image() The most important property of an image object is src This designates the actual image file you will use as a source for your Image object – objname.src= “abc.jpg” This property can be used to dynamically change an image on the webpage Basharat Mahmood, Department of Computer Science, CIIT, Islamabad, Pakistan 12

2. Working with images…. The primary use for an Image object is to download an image into the cache before it is actually needed for display – Instance of image object is created – Src property is set to the name of the image to be downloaded Basharat Mahmood, Department of Computer Science, CIIT, Islamabad, Pakistan 13

2.1 Image Rollover Function starts Setting the Src Img tag Calling the functionAgain calling the function Basharat Mahmood, Department of Computer Science, CIIT, Islamabad, Pakistan 14

2.2 Image Preview Main image Small images Image src Call to the function Src is passed Basharat Mahmood, Department of Computer Science, CIIT, Islamabad, Pakistan 15

2.2 Image Preview… Function gets the src Src of main image is changed Basharat Mahmood, Department of Computer Science, CIIT, Islamabad, Pakistan 16

2.3 Slide Show Array of images Main image Next and previous image buttons Next image and previous image functions Basharat Mahmood, Department of Computer Science, CIIT, Islamabad, Pakistan 17

2.3 Slide Show… Basharat Mahmood, Department of Computer Science, CIIT, Islamabad, Pakistan 18 Array of images Length of pics array Next Pic Increase the index of pics Checks for last image Changes the image Set count incase of last image

2.3 Slide Show… Basharat Mahmood, Department of Computer Science, CIIT, Islamabad, Pakistan 19 Decrements the count Checks for the first image Changes the picture Sets the count incase of first image

2.3 Slide Show Basharat Mahmood, Department of Computer Science, CIIT, Islamabad, Pakistan 20 Main image Next image Call to the next function Back image Call to the previous functions

3. Working with date object The Date object is used to work with dates and times It can be used to find the current time and date Many time based tasks can be performed Date objects are created as var today=new Date() Basharat Mahmood, Department of Computer Science, CIIT, Islamabad, Pakistan 21

3. Working with date object… Date object methods: getDate(): – Returns the day of the month (from 1-31) getDay(): – Returns the day of the week (from 0-6) getFullYear(): – Returns the year (four digits) getMonth(): – Returns the month (from 0-11) Basharat Mahmood, Department of Computer Science, CIIT, Islamabad, Pakistan 22

3. Working with date object… getHours(): – Returns the hour (from 0-23) getMilliseconds(): – Returns the milliseconds (from 0-999) getMinutes(): – Returns the minutes (from 0-59) getSeconds(): – Returns the seconds (from 0-59) Basharat Mahmood, Department of Computer Science, CIIT, Islamabad, Pakistan 23

3.1 Digital clock Date object is created Gets hours Gets minutes Gets seconds Calls check-time function Writes time on txt div Function calls itself Basharat Mahmood, Department of Computer Science, CIIT, Islamabad, Pakistan 24

3. Working with date object… Concatenate ‘0’ if time is less than 10 First call to the function Empty div to display time Basharat Mahmood, Department of Computer Science, CIIT, Islamabad, Pakistan 25

Summary Controlling the background dynamically – Bgcolor – Text – background Working with images – Image rollover – Image preview – Image slide show Date object – Digital clock Basharat Mahmood, Department of Computer Science, CIIT, Islamabad, Pakistan 26

Chapter 11. Beginning HTML, XHTML,CSS, and JavaScript, by Jon Duckett, Wiley Publishing; 2009, ISBN: Chapter 4,5,7. Learn JavaScript, by Chuck Easttom, Wordware Publishing; 2002, ISBN Basharat Mahmood, Department of Computer Science, CIIT, Islamabad, Pakistan References