SlideShare a Scribd company logo
1
CS101 Introduction to Computing
Lecture 41Images & Animation
(Web Development Lecture 14)
2
During the last lecture we discussed
String Manipulation
• We became familiar with methods used for
manipulating strings
• We became able to solve simple problems
involving strings
3
String Manipulation in JavaScript
• In addition to the concatenation operator (+)
JavaScript supports several advanced string
operations as well
• Notationaly, these functions are accessed by
referring to various methods of the String object
• Moreover, this object also contains the ‘length’
property
4
String Methods
FORMAT
string.methodName( )
EXAMPLE:
name = “Bhola” ;
document.write( name.toUpperCase( ) ) ;
document.write( name.bold( ) ) ;
BHOLABhola
5
Two Types of String Methods
1. HTML Shortcuts
2. All Others
6
String Methods: HTML Shortcuts
bold( )
italics( )
strike( )
sub( )
sup( )
big( )
small( )
fontsize( n )
fixed( )
fontcolor( color )
link( URL )
7
String Methods: All Others
split( delimiter )
toLowerCase( )
toUpperCase( )
charAt( n )
substring( n, m )
indexOf( substring, n )
lastIndexOf( substring, n )
8
Automatic Conversion to Strings
• Whenever a non-string is used where
JavaScript is expecting a string, it converts that
non-string into a string
• Example:
– The document.write( ) method expects a string (or
several strings, separated by commas) as its
argument
– When a number or a Boolean is passed as an
argument to this method, JavaScript automatically
converts it into a string before writing it onto the
document
9
The ‘+’ Operator
• When ‘+’ is used with numeric operands, it
adds them
• When it is used with string operands, it
concatenates them
• When one operand is a string, and the other is
not, the non-string will first be converted to a
string and then the two strings will be
concatenated
10
Strings In Mathematical Expressions
When a string is used in a mathematical context,
if appropriate, JavaScript first converts it into a
number. Otherwise, a “NaN” is the result
document.write( "2" * Math.PI ) ;
document.write( "Yes" ^ 43 ) ;
NaN
6.283185307179586
11
The ‘toString’ Method
Explicit conversion to a string
EXAMPLE:
Convert 100.553478 into a currency format
a = 100.553478 ;
b = a.toString( ) ;
decimalPos = b.indexOf( ".", 0 ) ;
c = b.substring( 0, decimalPos + 3 ) ;
document.write( c ) ;
100.55
12
Conversion from Strings
parseInt( ) and parseFloat( ) methods
13
Today’s Goal
(Images & Animation)
• To become able to add and manipulate images
and simple animations to a Web page
14
Images in HTML
• It is quite straight forward to include gif and jpg
images in an html Web page using the <IMG>
tag
• Format: <IMG src=URL, alt=text
height=pixels width=pixels
align="bottom|middle|top">
• Plea: Don’t use images just for the sake of it!
15
16
<HTML><HEAD>
<TITLE>Image Demo</TITLE>
</HEAD><BODY>
<H1>Image Demo</H1>
Here is an image <IMG src="die5.gif">
<IMG src="die5.gif" height="63" width="126">
<P>
Here is another <IMG align="middle" src=
"http://www.vu.edu.pk/images/logo/logotop.jpg">
</BODY></HTML>
17
Images in JavaScript
• Images in JavaScript can be manipulated in
many ways using the built-in object Image
• Properties: name, border, complete, height,
width, hspace, vspace, lowsrc, src
• Methods: None
• Event handlers: onAbort, onError, onLoad, etc.
18
Image Preloading
• The primary use for an Image object is to
download an image into the cache before it is
actually needed for display
• This technique can be used to create smooth
animations or to display one of several images
based on the requirement
19
The Image Pre-Loading Process
1. An instance of the Image object is created
using the new keyword
2. The src property of this instance is set equal to
the filename of the image to be pre-loaded
3. That step starts the down-loading of the image
into the cache without actually displaying it
4. When a pre-loaded image is required to be
displayed, the src property of the displayed
image is set to the src property of the pre-
fetched image
20
Let us revisit an example that we first
saw in lecture 35
21
* * * *
22
23
die1.gif die2.gif die3.gif
die4.gif die5.gif die6.gif
24
<HTML>
<HEAD>
<TITLE>Roll the
Die</TITLE>
<SCRIPT>
JavaScript Code
</SCRIPT>
</HEAD>
<BODY >
HTML Code
</BODY>
25
<IMG name="die" src="die6.gif">
<FORM>
<INPUT type="button" value="Roll the Die"
onClick="rollDie( )">
</FORM>
26
dieImg = new Array( 7 ) ;
for( k = 1; k < 7; k = k + 1 ) { //Preload images
dieImg[ k ] = new Image( ) ;
dieImg[ k ].src = "die" + k + ".gif" ;
}
function rollDie( ) {
dieN = Math.ceil( 6 * Math.random( ) ) ;
document.die.src = dieImg[ dieN ].src ;
}
27
Another Example
• Develop a Web page that displays six
thumbnail images and a main image
• The main image should change to a larger
version of the thumbnail as soon as the
mouse moves over on a thumbnail image
28
29
<HTML>
<HEAD>
<TITLE>Image Selector</TITLE>
<SCRIPT>
JavaScript Code
</SCRIPT>
</HEAD>
<BODY >
HTML Code
</BODY>
</HTML>
30
dieImg = new Array( 7 ) ;
for( k = 1; k < 7; k = k + 1 ) { // Preload images
dieImg[ k ] = new Image( ) ;
dieImg[ k ].src = "die" + k + ".gif" ;
}
31
<IMG name="big" src="die6.gif"
width="252" height="252"><P>
<IMG src="die1.gif" width="63" height="63"
onMouseOver=
"document.big.src=dieImg[ 1 ].src">
…
…
<IMG src="die6.gif" width="63" height="63"
onMouseOver=
"document.big.src=dieImg[ 6 ].src">
32
Where Else Can We Use This?
• Automobile Web site
• ???
33
Animation Example 1
• Take 16 images and cycle through them to
create an animation effect
34
1 2 3 4
5 6 7 8
9 10 11 12
13 14 15 16
35
36
<HTML>
<HEAD>
<TITLE>Animation 1</TITLE>
<SCRIPT>
JavaScript Code
</SCRIPT>
</HEAD>
<BODY >
HTML Code
</BODY>
</HTML>
37
<CENTER>
<IMG name="circle" src="circle1.gif"
onLoad="setTimeout( 'circulate( )', gap )">
</CENTER>
setTimeout( ) executes
circulate( ) once after a
delay of gap milliseconds
38
gap = 100 ;
imageN = 1 ;
circImg = new Array( 17 ) ;
for( k = 1; k < 17; k = k + 1 ) { // Preload images
circImg[ k ] = new Image( ) ;
circImg[ k ].src = "circle" + k + ".gif" ;
}
39
function circulate( ) {
document.circle.src =
circImg[ imageN ].src ;
imageN = imageN + 1 ;
if( imageN > 16 )
imageN = 1 ;
}
40
41
Animated Gifs
• We could have saved the 16 gif images of the
previous example in a single file in the form of
an animated gif, and then used it in a regular
<IMG> tag to display a moving image
• However, JavaScript provides better control
over the sequencing and the gap between the
individual images
42
Animation Example 2
• Take 16 images and cycle through them to
create an animation effect
• Provide buttons to slow down or speed up
the animation
43
44
<HTML>
<HEAD>
<TITLE>Animation 2</TITLE>
<SCRIPT>
JavaScript Code
</SCRIPT>
</HEAD>
<BODY >
HTML Code
</BODY>
</HTML>
45
<CENTER>
<IMG name="circle" src="circle1.gif"
onLoad="setTimeout( 'circulate( )', gap )">
</CENTER>
<FORM>
<INPUT type="button" value="Slow Down"
onClick="slowDown( )">
<INPUT type="button" value="Speed Up"
onClick="speedUp( )">
</FORM>
46
gap = 100 ;
imageN = 1 ;
circImg = new Array( 17 ) ;
for( k = 1; k < 17; k = k + 1 ) { // Preload images
circImg[ k ] = new Image( ) ;
circImg[ k ].src = "circle" + k + ".gif" ;
}
No
change
47
function circulate( ) {
document.circle.src =
circImg[ imageN ].src ;
imageN = imageN + 1 ;
if( imageN > 16 )
imageN = 1 ;
}
No
change
48
function slowDown( ) {
gap = gap + 20 ;
if( gap > 4000 )
gap = 4000 ;
}
function speedUp( ) {
gap = gap - 20 ;
if( gap < 0 )
gap = 0 ;
}
Two new
functions
49
50
Flash Animation
• Designed for 2-D animations, but can be used
for storing static vector-images as well
• A special program (called a plug-in) is required
to view Flash files in a Web browser
• Can be used to design complete, animated
Web sites with hardly any HTML in it
• Binary-file storage
51
Structured Vector Graphics
• New format; may become more popular than
Flash
• Plug-in required
• Text-file storage; search engine friendly
52
During Today’s Lecture …
• We became able to add and manipulate
images and simple animations to a Web page
53
Our 15th
& Final Web Dev Lecture:
(Programming Methodology)
• To understand effective programming
practices that result in the development of
correct programs with minimum effort
• To become familiar with simple debugging
techniques

More Related Content

What's hot

HTML5って必要?
HTML5って必要?HTML5って必要?
HTML5って必要?
GCS2013
 
A Quick and Dirty D3.js Tutorial
A Quick and Dirty D3.js TutorialA Quick and Dirty D3.js Tutorial
A Quick and Dirty D3.js Tutorial
Young-Ho Kim
 
The Ring programming language version 1.4.1 book - Part 16 of 31
The Ring programming language version 1.4.1 book - Part 16 of 31The Ring programming language version 1.4.1 book - Part 16 of 31
The Ring programming language version 1.4.1 book - Part 16 of 31
Mahmoud Samir Fayed
 
The Ring programming language version 1.2 book - Part 41 of 84
The Ring programming language version 1.2 book - Part 41 of 84The Ring programming language version 1.2 book - Part 41 of 84
The Ring programming language version 1.2 book - Part 41 of 84
Mahmoud Samir Fayed
 
Introduction to d3js (and SVG)
Introduction to d3js (and SVG)Introduction to d3js (and SVG)
Introduction to d3js (and SVG)
zahid-mian
 
Михаил Матросов, Повседневный С++: boost и STL
Михаил Матросов, Повседневный С++: boost и STLМихаил Матросов, Повседневный С++: boost и STL
Михаил Матросов, Повседневный С++: boost и STL
Sergey Platonov
 
Sharbani bhattacharya sacta 2014
Sharbani bhattacharya sacta 2014Sharbani bhattacharya sacta 2014
Sharbani bhattacharya sacta 2014
Sharbani Bhattacharya
 
Lec 7 28_aug [compatibility mode]
Lec 7 28_aug [compatibility mode]Lec 7 28_aug [compatibility mode]
Lec 7 28_aug [compatibility mode]Palak Sanghani
 
Psimd open64 workshop_2012-new
Psimd open64 workshop_2012-newPsimd open64 workshop_2012-new
Psimd open64 workshop_2012-newdibyendu_das0708
 
Портируем существующее Web-приложение в виртуальную реальность / Денис Радин ...
Портируем существующее Web-приложение в виртуальную реальность / Денис Радин ...Портируем существующее Web-приложение в виртуальную реальность / Денис Радин ...
Портируем существующее Web-приложение в виртуальную реальность / Денис Радин ...
Ontico
 
Learn D3.js in 90 minutes
Learn D3.js in 90 minutesLearn D3.js in 90 minutes
Learn D3.js in 90 minutes
Jos Dirksen
 
Yui combo 005
Yui combo 005Yui combo 005
Yui combo 005
Karina Cauja
 
Data Binding in qooxdoo
Data Binding in qooxdooData Binding in qooxdoo
Data Binding in qooxdoo
Martin Wittemann
 
Pyramid Algorithm Framework for Real-Time Image Effects in Game Engines
Pyramid Algorithm Framework for Real-Time Image Effects in Game EnginesPyramid Algorithm Framework for Real-Time Image Effects in Game Engines
Pyramid Algorithm Framework for Real-Time Image Effects in Game Engines
Daniel Michelsanti
 
[Lecture 3] AI and Deep Learning: Logistic Regression (Coding)
[Lecture 3] AI and Deep Learning: Logistic Regression (Coding)[Lecture 3] AI and Deep Learning: Logistic Regression (Coding)
[Lecture 3] AI and Deep Learning: Logistic Regression (Coding)
Kobkrit Viriyayudhakorn
 
The Ring programming language version 1.5.3 book - Part 40 of 184
The Ring programming language version 1.5.3 book - Part 40 of 184The Ring programming language version 1.5.3 book - Part 40 of 184
The Ring programming language version 1.5.3 book - Part 40 of 184
Mahmoud Samir Fayed
 
D3 Basic Tutorial
D3 Basic TutorialD3 Basic Tutorial
D3 Basic TutorialTao Jiang
 
Datastructure tree
Datastructure treeDatastructure tree
Datastructure tree
rantd
 
Introduction to GGVIS Visualization
Introduction to GGVIS VisualizationIntroduction to GGVIS Visualization
Introduction to GGVIS Visualization
HemantSingh311
 

What's hot (20)

HTML5って必要?
HTML5って必要?HTML5って必要?
HTML5って必要?
 
D3.js workshop
D3.js workshopD3.js workshop
D3.js workshop
 
A Quick and Dirty D3.js Tutorial
A Quick and Dirty D3.js TutorialA Quick and Dirty D3.js Tutorial
A Quick and Dirty D3.js Tutorial
 
The Ring programming language version 1.4.1 book - Part 16 of 31
The Ring programming language version 1.4.1 book - Part 16 of 31The Ring programming language version 1.4.1 book - Part 16 of 31
The Ring programming language version 1.4.1 book - Part 16 of 31
 
The Ring programming language version 1.2 book - Part 41 of 84
The Ring programming language version 1.2 book - Part 41 of 84The Ring programming language version 1.2 book - Part 41 of 84
The Ring programming language version 1.2 book - Part 41 of 84
 
Introduction to d3js (and SVG)
Introduction to d3js (and SVG)Introduction to d3js (and SVG)
Introduction to d3js (and SVG)
 
Михаил Матросов, Повседневный С++: boost и STL
Михаил Матросов, Повседневный С++: boost и STLМихаил Матросов, Повседневный С++: boost и STL
Михаил Матросов, Повседневный С++: boost и STL
 
Sharbani bhattacharya sacta 2014
Sharbani bhattacharya sacta 2014Sharbani bhattacharya sacta 2014
Sharbani bhattacharya sacta 2014
 
Lec 7 28_aug [compatibility mode]
Lec 7 28_aug [compatibility mode]Lec 7 28_aug [compatibility mode]
Lec 7 28_aug [compatibility mode]
 
Psimd open64 workshop_2012-new
Psimd open64 workshop_2012-newPsimd open64 workshop_2012-new
Psimd open64 workshop_2012-new
 
Портируем существующее Web-приложение в виртуальную реальность / Денис Радин ...
Портируем существующее Web-приложение в виртуальную реальность / Денис Радин ...Портируем существующее Web-приложение в виртуальную реальность / Денис Радин ...
Портируем существующее Web-приложение в виртуальную реальность / Денис Радин ...
 
Learn D3.js in 90 minutes
Learn D3.js in 90 minutesLearn D3.js in 90 minutes
Learn D3.js in 90 minutes
 
Yui combo 005
Yui combo 005Yui combo 005
Yui combo 005
 
Data Binding in qooxdoo
Data Binding in qooxdooData Binding in qooxdoo
Data Binding in qooxdoo
 
Pyramid Algorithm Framework for Real-Time Image Effects in Game Engines
Pyramid Algorithm Framework for Real-Time Image Effects in Game EnginesPyramid Algorithm Framework for Real-Time Image Effects in Game Engines
Pyramid Algorithm Framework for Real-Time Image Effects in Game Engines
 
[Lecture 3] AI and Deep Learning: Logistic Regression (Coding)
[Lecture 3] AI and Deep Learning: Logistic Regression (Coding)[Lecture 3] AI and Deep Learning: Logistic Regression (Coding)
[Lecture 3] AI and Deep Learning: Logistic Regression (Coding)
 
The Ring programming language version 1.5.3 book - Part 40 of 184
The Ring programming language version 1.5.3 book - Part 40 of 184The Ring programming language version 1.5.3 book - Part 40 of 184
The Ring programming language version 1.5.3 book - Part 40 of 184
 
D3 Basic Tutorial
D3 Basic TutorialD3 Basic Tutorial
D3 Basic Tutorial
 
Datastructure tree
Datastructure treeDatastructure tree
Datastructure tree
 
Introduction to GGVIS Visualization
Introduction to GGVIS VisualizationIntroduction to GGVIS Visualization
Introduction to GGVIS Visualization
 

Viewers also liked

Kids Party Decoration Supplies Online
Kids Party Decoration Supplies Online Kids Party Decoration Supplies Online
Kids Party Decoration Supplies Online
JoeCavallaro
 
Botón de mano y volante de mano
Botón de mano y volante de manoBotón de mano y volante de mano
Botón de mano y volante de mano
Francisco Melgarejo Rodriguez
 
IT security - continuïteit van uw onderneming - Orbid
IT security - continuïteit van uw onderneming - OrbidIT security - continuïteit van uw onderneming - Orbid
IT security - continuïteit van uw onderneming - Orbid
Orbid
 
CS201- Introduction to Programming- Lecture 23
CS201- Introduction to Programming- Lecture 23CS201- Introduction to Programming- Lecture 23
CS201- Introduction to Programming- Lecture 23
Bilal Ahmed
 
Kid’s party decorations ideas
Kid’s party decorations ideasKid’s party decorations ideas
Kid’s party decorations ideas
JoeCavallaro
 
CS201- Introduction to Programming- Lecture 29
CS201- Introduction to Programming- Lecture 29CS201- Introduction to Programming- Lecture 29
CS201- Introduction to Programming- Lecture 29
Bilal Ahmed
 
Aml catalogue 13
Aml catalogue 13Aml catalogue 13
Aml catalogue 13slideroma
 
Wall quote vinyl decal
Wall quote vinyl decalWall quote vinyl decal
Wall quote vinyl decal
vinyldecors
 
CS201- Introduction to Programming- Lecture 20
CS201- Introduction to Programming- Lecture 20CS201- Introduction to Programming- Lecture 20
CS201- Introduction to Programming- Lecture 20
Bilal Ahmed
 
MGT101 - Financial Accounting- Lecture 37
MGT101 - Financial Accounting- Lecture 37MGT101 - Financial Accounting- Lecture 37
MGT101 - Financial Accounting- Lecture 37
Bilal Ahmed
 
Untuk presentasi
Untuk presentasi Untuk presentasi
Untuk presentasi
Nur Alfiyatur Rochmah
 
Konseo dasar jurnalistik2
Konseo dasar jurnalistik2Konseo dasar jurnalistik2
Konseo dasar jurnalistik2
Nur Alfiyatur Rochmah
 
Professionaliseer uw technische dienst en facility management
Professionaliseer uw technische dienst en facility managementProfessionaliseer uw technische dienst en facility management
Professionaliseer uw technische dienst en facility management
Orbid
 
CS201- Introduction to Programming- Lecture 13
CS201- Introduction to Programming- Lecture 13CS201- Introduction to Programming- Lecture 13
CS201- Introduction to Programming- Lecture 13
Bilal Ahmed
 
ENG101- English Comprehension- Lecture 31
ENG101- English Comprehension- Lecture 31ENG101- English Comprehension- Lecture 31
ENG101- English Comprehension- Lecture 31
Bilal Ahmed
 
בשביל החייםשלי♥♥♥♥
בשביל החייםשלי♥♥♥♥בשביל החייםשלי♥♥♥♥
בשביל החייםשלי♥♥♥♥
Avi Avraham
 

Viewers also liked (20)

Bab i, ii, iii
Bab i, ii, iiiBab i, ii, iii
Bab i, ii, iii
 
Kids Party Decoration Supplies Online
Kids Party Decoration Supplies Online Kids Party Decoration Supplies Online
Kids Party Decoration Supplies Online
 
Botón de mano y volante de mano
Botón de mano y volante de manoBotón de mano y volante de mano
Botón de mano y volante de mano
 
IT security - continuïteit van uw onderneming - Orbid
IT security - continuïteit van uw onderneming - OrbidIT security - continuïteit van uw onderneming - Orbid
IT security - continuïteit van uw onderneming - Orbid
 
CS201- Introduction to Programming- Lecture 23
CS201- Introduction to Programming- Lecture 23CS201- Introduction to Programming- Lecture 23
CS201- Introduction to Programming- Lecture 23
 
Kid’s party decorations ideas
Kid’s party decorations ideasKid’s party decorations ideas
Kid’s party decorations ideas
 
CS201- Introduction to Programming- Lecture 29
CS201- Introduction to Programming- Lecture 29CS201- Introduction to Programming- Lecture 29
CS201- Introduction to Programming- Lecture 29
 
Aml catalogue 13
Aml catalogue 13Aml catalogue 13
Aml catalogue 13
 
Wall quote vinyl decal
Wall quote vinyl decalWall quote vinyl decal
Wall quote vinyl decal
 
CS201- Introduction to Programming- Lecture 20
CS201- Introduction to Programming- Lecture 20CS201- Introduction to Programming- Lecture 20
CS201- Introduction to Programming- Lecture 20
 
MGT101 - Financial Accounting- Lecture 37
MGT101 - Financial Accounting- Lecture 37MGT101 - Financial Accounting- Lecture 37
MGT101 - Financial Accounting- Lecture 37
 
Untuk presentasi
Untuk presentasi Untuk presentasi
Untuk presentasi
 
Hukum islam
Hukum islamHukum islam
Hukum islam
 
Konseo dasar jurnalistik2
Konseo dasar jurnalistik2Konseo dasar jurnalistik2
Konseo dasar jurnalistik2
 
Kelompok 2
Kelompok 2Kelompok 2
Kelompok 2
 
Professionaliseer uw technische dienst en facility management
Professionaliseer uw technische dienst en facility managementProfessionaliseer uw technische dienst en facility management
Professionaliseer uw technische dienst en facility management
 
CS201- Introduction to Programming- Lecture 13
CS201- Introduction to Programming- Lecture 13CS201- Introduction to Programming- Lecture 13
CS201- Introduction to Programming- Lecture 13
 
ENG101- English Comprehension- Lecture 31
ENG101- English Comprehension- Lecture 31ENG101- English Comprehension- Lecture 31
ENG101- English Comprehension- Lecture 31
 
בשביל החייםשלי♥♥♥♥
בשביל החייםשלי♥♥♥♥בשביל החייםשלי♥♥♥♥
בשביל החייםשלי♥♥♥♥
 
K om non verbal
K om non verbalK om non verbal
K om non verbal
 

Similar to CS101- Introduction to Computing- Lecture 41

Building a fast web experience [beta]
Building a fast web experience [beta]Building a fast web experience [beta]
Building a fast web experience [beta]Kirk Yamamoto
 
javascript examples
javascript examplesjavascript examples
javascript examples
Egerton University
 
18CSC311J WEB DESIGN AND DEVELPMENT UNIT-1
18CSC311J WEB DESIGN AND DEVELPMENT UNIT-118CSC311J WEB DESIGN AND DEVELPMENT UNIT-1
18CSC311J WEB DESIGN AND DEVELPMENT UNIT-1
sivakumarmcs
 
The Ring programming language version 1.5.1 book - Part 28 of 180
The Ring programming language version 1.5.1 book - Part 28 of 180The Ring programming language version 1.5.1 book - Part 28 of 180
The Ring programming language version 1.5.1 book - Part 28 of 180
Mahmoud Samir Fayed
 
CSS3 Takes on the World
CSS3 Takes on the WorldCSS3 Takes on the World
CSS3 Takes on the World
Jonathan Snook
 
VMWorld 2017 Hackathon training: Getting Started with Clarity
VMWorld 2017 Hackathon training: Getting Started with ClarityVMWorld 2017 Hackathon training: Getting Started with Clarity
VMWorld 2017 Hackathon training: Getting Started with Clarity
Jeeyun Lim
 
The Ring programming language version 1.5.2 book - Part 29 of 181
The Ring programming language version 1.5.2 book - Part 29 of 181The Ring programming language version 1.5.2 book - Part 29 of 181
The Ring programming language version 1.5.2 book - Part 29 of 181
Mahmoud Samir Fayed
 
The Ring programming language version 1.4 book - Part 8 of 30
The Ring programming language version 1.4 book - Part 8 of 30The Ring programming language version 1.4 book - Part 8 of 30
The Ring programming language version 1.4 book - Part 8 of 30
Mahmoud Samir Fayed
 
bfd23fd7-0d89-45c0-8b82-c991b30ed375.pdf
bfd23fd7-0d89-45c0-8b82-c991b30ed375.pdfbfd23fd7-0d89-45c0-8b82-c991b30ed375.pdf
bfd23fd7-0d89-45c0-8b82-c991b30ed375.pdf
shehabhamad_90
 
The Ring programming language version 1.7 book - Part 48 of 196
The Ring programming language version 1.7 book - Part 48 of 196The Ring programming language version 1.7 book - Part 48 of 196
The Ring programming language version 1.7 book - Part 48 of 196
Mahmoud Samir Fayed
 
HTML5: where flash isn't needed anymore
HTML5: where flash isn't needed anymoreHTML5: where flash isn't needed anymore
HTML5: where flash isn't needed anymore
Remy Sharp
 
The Ring programming language version 1.5 book - Part 8 of 31
The Ring programming language version 1.5 book - Part 8 of 31The Ring programming language version 1.5 book - Part 8 of 31
The Ring programming language version 1.5 book - Part 8 of 31
Mahmoud Samir Fayed
 
CS101- Introduction to Computing- Lecture 35
CS101- Introduction to Computing- Lecture 35CS101- Introduction to Computing- Lecture 35
CS101- Introduction to Computing- Lecture 35
Bilal Ahmed
 
Svcc 2013-d3
Svcc 2013-d3Svcc 2013-d3
Svcc 2013-d3
Oswald Campesato
 
SVCC 2013 D3.js Presentation (10/05/2013)
SVCC 2013 D3.js Presentation (10/05/2013)SVCC 2013 D3.js Presentation (10/05/2013)
SVCC 2013 D3.js Presentation (10/05/2013)
Oswald Campesato
 
I Can't Believe It's Not Flash
I Can't Believe It's Not FlashI Can't Believe It's Not Flash
I Can't Believe It's Not Flash
Thomas Fuchs
 

Similar to CS101- Introduction to Computing- Lecture 41 (20)

Building a fast web experience [beta]
Building a fast web experience [beta]Building a fast web experience [beta]
Building a fast web experience [beta]
 
javascript examples
javascript examplesjavascript examples
javascript examples
 
18CSC311J WEB DESIGN AND DEVELPMENT UNIT-1
18CSC311J WEB DESIGN AND DEVELPMENT UNIT-118CSC311J WEB DESIGN AND DEVELPMENT UNIT-1
18CSC311J WEB DESIGN AND DEVELPMENT UNIT-1
 
The Ring programming language version 1.5.1 book - Part 28 of 180
The Ring programming language version 1.5.1 book - Part 28 of 180The Ring programming language version 1.5.1 book - Part 28 of 180
The Ring programming language version 1.5.1 book - Part 28 of 180
 
CSS3 Takes on the World
CSS3 Takes on the WorldCSS3 Takes on the World
CSS3 Takes on the World
 
VMWorld 2017 Hackathon training: Getting Started with Clarity
VMWorld 2017 Hackathon training: Getting Started with ClarityVMWorld 2017 Hackathon training: Getting Started with Clarity
VMWorld 2017 Hackathon training: Getting Started with Clarity
 
The Ring programming language version 1.5.2 book - Part 29 of 181
The Ring programming language version 1.5.2 book - Part 29 of 181The Ring programming language version 1.5.2 book - Part 29 of 181
The Ring programming language version 1.5.2 book - Part 29 of 181
 
The Ring programming language version 1.4 book - Part 8 of 30
The Ring programming language version 1.4 book - Part 8 of 30The Ring programming language version 1.4 book - Part 8 of 30
The Ring programming language version 1.4 book - Part 8 of 30
 
bfd23fd7-0d89-45c0-8b82-c991b30ed375.pdf
bfd23fd7-0d89-45c0-8b82-c991b30ed375.pdfbfd23fd7-0d89-45c0-8b82-c991b30ed375.pdf
bfd23fd7-0d89-45c0-8b82-c991b30ed375.pdf
 
The Ring programming language version 1.7 book - Part 48 of 196
The Ring programming language version 1.7 book - Part 48 of 196The Ring programming language version 1.7 book - Part 48 of 196
The Ring programming language version 1.7 book - Part 48 of 196
 
HTML5: where flash isn't needed anymore
HTML5: where flash isn't needed anymoreHTML5: where flash isn't needed anymore
HTML5: where flash isn't needed anymore
 
The Ring programming language version 1.5 book - Part 8 of 31
The Ring programming language version 1.5 book - Part 8 of 31The Ring programming language version 1.5 book - Part 8 of 31
The Ring programming language version 1.5 book - Part 8 of 31
 
CS101- Introduction to Computing- Lecture 35
CS101- Introduction to Computing- Lecture 35CS101- Introduction to Computing- Lecture 35
CS101- Introduction to Computing- Lecture 35
 
Svcc 2013-d3
Svcc 2013-d3Svcc 2013-d3
Svcc 2013-d3
 
SVCC 2013 D3.js Presentation (10/05/2013)
SVCC 2013 D3.js Presentation (10/05/2013)SVCC 2013 D3.js Presentation (10/05/2013)
SVCC 2013 D3.js Presentation (10/05/2013)
 
Intro to HTML5
Intro to HTML5Intro to HTML5
Intro to HTML5
 
Cpp tutorial
Cpp tutorialCpp tutorial
Cpp tutorial
 
Class19
Class19Class19
Class19
 
GCD in Action
GCD in ActionGCD in Action
GCD in Action
 
I Can't Believe It's Not Flash
I Can't Believe It's Not FlashI Can't Believe It's Not Flash
I Can't Believe It's Not Flash
 

More from Bilal Ahmed

CS201- Introduction to Programming- Lecture 45
CS201- Introduction to Programming- Lecture 45CS201- Introduction to Programming- Lecture 45
CS201- Introduction to Programming- Lecture 45
Bilal Ahmed
 
CS201- Introduction to Programming- Lecture 44
CS201- Introduction to Programming- Lecture 44CS201- Introduction to Programming- Lecture 44
CS201- Introduction to Programming- Lecture 44
Bilal Ahmed
 
CS201- Introduction to Programming- Lecture 43
CS201- Introduction to Programming- Lecture 43CS201- Introduction to Programming- Lecture 43
CS201- Introduction to Programming- Lecture 43
Bilal Ahmed
 
CS201- Introduction to Programming- Lecture 42
CS201- Introduction to Programming- Lecture 42CS201- Introduction to Programming- Lecture 42
CS201- Introduction to Programming- Lecture 42
Bilal Ahmed
 
CS201- Introduction to Programming- Lecture 41
CS201- Introduction to Programming- Lecture 41CS201- Introduction to Programming- Lecture 41
CS201- Introduction to Programming- Lecture 41
Bilal Ahmed
 
CS201- Introduction to Programming- Lecture 40
CS201- Introduction to Programming- Lecture 40CS201- Introduction to Programming- Lecture 40
CS201- Introduction to Programming- Lecture 40
Bilal Ahmed
 
CS201- Introduction to Programming- Lecture 39
CS201- Introduction to Programming- Lecture 39CS201- Introduction to Programming- Lecture 39
CS201- Introduction to Programming- Lecture 39
Bilal Ahmed
 
CS201- Introduction to Programming- Lecture 38
CS201- Introduction to Programming- Lecture 38CS201- Introduction to Programming- Lecture 38
CS201- Introduction to Programming- Lecture 38
Bilal Ahmed
 
CS201- Introduction to Programming- Lecture 37
CS201- Introduction to Programming- Lecture 37CS201- Introduction to Programming- Lecture 37
CS201- Introduction to Programming- Lecture 37
Bilal Ahmed
 
CS201- Introduction to Programming- Lecture 36
CS201- Introduction to Programming- Lecture 36CS201- Introduction to Programming- Lecture 36
CS201- Introduction to Programming- Lecture 36
Bilal Ahmed
 
CS201- Introduction to Programming- Lecture 35
CS201- Introduction to Programming- Lecture 35CS201- Introduction to Programming- Lecture 35
CS201- Introduction to Programming- Lecture 35
Bilal Ahmed
 
CS201- Introduction to Programming- Lecture 34
CS201- Introduction to Programming- Lecture 34CS201- Introduction to Programming- Lecture 34
CS201- Introduction to Programming- Lecture 34
Bilal Ahmed
 
CS201- Introduction to Programming- Lecture 33
CS201- Introduction to Programming- Lecture 33CS201- Introduction to Programming- Lecture 33
CS201- Introduction to Programming- Lecture 33
Bilal Ahmed
 
CS201- Introduction to Programming- Lecture 32
CS201- Introduction to Programming- Lecture 32CS201- Introduction to Programming- Lecture 32
CS201- Introduction to Programming- Lecture 32
Bilal Ahmed
 
CS201- Introduction to Programming- Lecture 31
CS201- Introduction to Programming- Lecture 31CS201- Introduction to Programming- Lecture 31
CS201- Introduction to Programming- Lecture 31
Bilal Ahmed
 
CS201- Introduction to Programming- Lecture 30
CS201- Introduction to Programming- Lecture 30CS201- Introduction to Programming- Lecture 30
CS201- Introduction to Programming- Lecture 30
Bilal Ahmed
 
CS201- Introduction to Programming- Lecture 28
CS201- Introduction to Programming- Lecture 28CS201- Introduction to Programming- Lecture 28
CS201- Introduction to Programming- Lecture 28
Bilal Ahmed
 
CS201- Introduction to Programming- Lecture 27
CS201- Introduction to Programming- Lecture 27CS201- Introduction to Programming- Lecture 27
CS201- Introduction to Programming- Lecture 27
Bilal Ahmed
 
CS201- Introduction to Programming- Lecture 26
CS201- Introduction to Programming- Lecture 26CS201- Introduction to Programming- Lecture 26
CS201- Introduction to Programming- Lecture 26
Bilal Ahmed
 
CS201- Introduction to Programming- Lecture 25
CS201- Introduction to Programming- Lecture 25CS201- Introduction to Programming- Lecture 25
CS201- Introduction to Programming- Lecture 25
Bilal Ahmed
 

More from Bilal Ahmed (20)

CS201- Introduction to Programming- Lecture 45
CS201- Introduction to Programming- Lecture 45CS201- Introduction to Programming- Lecture 45
CS201- Introduction to Programming- Lecture 45
 
CS201- Introduction to Programming- Lecture 44
CS201- Introduction to Programming- Lecture 44CS201- Introduction to Programming- Lecture 44
CS201- Introduction to Programming- Lecture 44
 
CS201- Introduction to Programming- Lecture 43
CS201- Introduction to Programming- Lecture 43CS201- Introduction to Programming- Lecture 43
CS201- Introduction to Programming- Lecture 43
 
CS201- Introduction to Programming- Lecture 42
CS201- Introduction to Programming- Lecture 42CS201- Introduction to Programming- Lecture 42
CS201- Introduction to Programming- Lecture 42
 
CS201- Introduction to Programming- Lecture 41
CS201- Introduction to Programming- Lecture 41CS201- Introduction to Programming- Lecture 41
CS201- Introduction to Programming- Lecture 41
 
CS201- Introduction to Programming- Lecture 40
CS201- Introduction to Programming- Lecture 40CS201- Introduction to Programming- Lecture 40
CS201- Introduction to Programming- Lecture 40
 
CS201- Introduction to Programming- Lecture 39
CS201- Introduction to Programming- Lecture 39CS201- Introduction to Programming- Lecture 39
CS201- Introduction to Programming- Lecture 39
 
CS201- Introduction to Programming- Lecture 38
CS201- Introduction to Programming- Lecture 38CS201- Introduction to Programming- Lecture 38
CS201- Introduction to Programming- Lecture 38
 
CS201- Introduction to Programming- Lecture 37
CS201- Introduction to Programming- Lecture 37CS201- Introduction to Programming- Lecture 37
CS201- Introduction to Programming- Lecture 37
 
CS201- Introduction to Programming- Lecture 36
CS201- Introduction to Programming- Lecture 36CS201- Introduction to Programming- Lecture 36
CS201- Introduction to Programming- Lecture 36
 
CS201- Introduction to Programming- Lecture 35
CS201- Introduction to Programming- Lecture 35CS201- Introduction to Programming- Lecture 35
CS201- Introduction to Programming- Lecture 35
 
CS201- Introduction to Programming- Lecture 34
CS201- Introduction to Programming- Lecture 34CS201- Introduction to Programming- Lecture 34
CS201- Introduction to Programming- Lecture 34
 
CS201- Introduction to Programming- Lecture 33
CS201- Introduction to Programming- Lecture 33CS201- Introduction to Programming- Lecture 33
CS201- Introduction to Programming- Lecture 33
 
CS201- Introduction to Programming- Lecture 32
CS201- Introduction to Programming- Lecture 32CS201- Introduction to Programming- Lecture 32
CS201- Introduction to Programming- Lecture 32
 
CS201- Introduction to Programming- Lecture 31
CS201- Introduction to Programming- Lecture 31CS201- Introduction to Programming- Lecture 31
CS201- Introduction to Programming- Lecture 31
 
CS201- Introduction to Programming- Lecture 30
CS201- Introduction to Programming- Lecture 30CS201- Introduction to Programming- Lecture 30
CS201- Introduction to Programming- Lecture 30
 
CS201- Introduction to Programming- Lecture 28
CS201- Introduction to Programming- Lecture 28CS201- Introduction to Programming- Lecture 28
CS201- Introduction to Programming- Lecture 28
 
CS201- Introduction to Programming- Lecture 27
CS201- Introduction to Programming- Lecture 27CS201- Introduction to Programming- Lecture 27
CS201- Introduction to Programming- Lecture 27
 
CS201- Introduction to Programming- Lecture 26
CS201- Introduction to Programming- Lecture 26CS201- Introduction to Programming- Lecture 26
CS201- Introduction to Programming- Lecture 26
 
CS201- Introduction to Programming- Lecture 25
CS201- Introduction to Programming- Lecture 25CS201- Introduction to Programming- Lecture 25
CS201- Introduction to Programming- Lecture 25
 

Recently uploaded

A Strategic Approach: GenAI in Education
A Strategic Approach: GenAI in EducationA Strategic Approach: GenAI in Education
A Strategic Approach: GenAI in Education
Peter Windle
 
Sha'Carri Richardson Presentation 202345
Sha'Carri Richardson Presentation 202345Sha'Carri Richardson Presentation 202345
Sha'Carri Richardson Presentation 202345
beazzy04
 
The basics of sentences session 5pptx.pptx
The basics of sentences session 5pptx.pptxThe basics of sentences session 5pptx.pptx
The basics of sentences session 5pptx.pptx
heathfieldcps1
 
Language Across the Curriculm LAC B.Ed.
Language Across the  Curriculm LAC B.Ed.Language Across the  Curriculm LAC B.Ed.
Language Across the Curriculm LAC B.Ed.
Atul Kumar Singh
 
The geography of Taylor Swift - some ideas
The geography of Taylor Swift - some ideasThe geography of Taylor Swift - some ideas
The geography of Taylor Swift - some ideas
GeoBlogs
 
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
Levi Shapiro
 
CACJapan - GROUP Presentation 1- Wk 4.pdf
CACJapan - GROUP Presentation 1- Wk 4.pdfCACJapan - GROUP Presentation 1- Wk 4.pdf
CACJapan - GROUP Presentation 1- Wk 4.pdf
camakaiclarkmusic
 
Supporting (UKRI) OA monographs at Salford.pptx
Supporting (UKRI) OA monographs at Salford.pptxSupporting (UKRI) OA monographs at Salford.pptx
Supporting (UKRI) OA monographs at Salford.pptx
Jisc
 
Additional Benefits for Employee Website.pdf
Additional Benefits for Employee Website.pdfAdditional Benefits for Employee Website.pdf
Additional Benefits for Employee Website.pdf
joachimlavalley1
 
Instructions for Submissions thorugh G- Classroom.pptx
Instructions for Submissions thorugh G- Classroom.pptxInstructions for Submissions thorugh G- Classroom.pptx
Instructions for Submissions thorugh G- Classroom.pptx
Jheel Barad
 
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
MysoreMuleSoftMeetup
 
Introduction to AI for Nonprofits with Tapp Network
Introduction to AI for Nonprofits with Tapp NetworkIntroduction to AI for Nonprofits with Tapp Network
Introduction to AI for Nonprofits with Tapp Network
TechSoup
 
special B.ed 2nd year old paper_20240531.pdf
special B.ed 2nd year old paper_20240531.pdfspecial B.ed 2nd year old paper_20240531.pdf
special B.ed 2nd year old paper_20240531.pdf
Special education needs
 
How to Make a Field invisible in Odoo 17
How to Make a Field invisible in Odoo 17How to Make a Field invisible in Odoo 17
How to Make a Field invisible in Odoo 17
Celine George
 
Unit 2- Research Aptitude (UGC NET Paper I).pdf
Unit 2- Research Aptitude (UGC NET Paper I).pdfUnit 2- Research Aptitude (UGC NET Paper I).pdf
Unit 2- Research Aptitude (UGC NET Paper I).pdf
Thiyagu K
 
678020731-Sumas-y-Restas-Para-Colorear.pdf
678020731-Sumas-y-Restas-Para-Colorear.pdf678020731-Sumas-y-Restas-Para-Colorear.pdf
678020731-Sumas-y-Restas-Para-Colorear.pdf
CarlosHernanMontoyab2
 
Francesca Gottschalk - How can education support child empowerment.pptx
Francesca Gottschalk - How can education support child empowerment.pptxFrancesca Gottschalk - How can education support child empowerment.pptx
Francesca Gottschalk - How can education support child empowerment.pptx
EduSkills OECD
 
2024.06.01 Introducing a competency framework for languag learning materials ...
2024.06.01 Introducing a competency framework for languag learning materials ...2024.06.01 Introducing a competency framework for languag learning materials ...
2024.06.01 Introducing a competency framework for languag learning materials ...
Sandy Millin
 
Model Attribute Check Company Auto Property
Model Attribute  Check Company Auto PropertyModel Attribute  Check Company Auto Property
Model Attribute Check Company Auto Property
Celine George
 
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
siemaillard
 

Recently uploaded (20)

A Strategic Approach: GenAI in Education
A Strategic Approach: GenAI in EducationA Strategic Approach: GenAI in Education
A Strategic Approach: GenAI in Education
 
Sha'Carri Richardson Presentation 202345
Sha'Carri Richardson Presentation 202345Sha'Carri Richardson Presentation 202345
Sha'Carri Richardson Presentation 202345
 
The basics of sentences session 5pptx.pptx
The basics of sentences session 5pptx.pptxThe basics of sentences session 5pptx.pptx
The basics of sentences session 5pptx.pptx
 
Language Across the Curriculm LAC B.Ed.
Language Across the  Curriculm LAC B.Ed.Language Across the  Curriculm LAC B.Ed.
Language Across the Curriculm LAC B.Ed.
 
The geography of Taylor Swift - some ideas
The geography of Taylor Swift - some ideasThe geography of Taylor Swift - some ideas
The geography of Taylor Swift - some ideas
 
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
 
CACJapan - GROUP Presentation 1- Wk 4.pdf
CACJapan - GROUP Presentation 1- Wk 4.pdfCACJapan - GROUP Presentation 1- Wk 4.pdf
CACJapan - GROUP Presentation 1- Wk 4.pdf
 
Supporting (UKRI) OA monographs at Salford.pptx
Supporting (UKRI) OA monographs at Salford.pptxSupporting (UKRI) OA monographs at Salford.pptx
Supporting (UKRI) OA monographs at Salford.pptx
 
Additional Benefits for Employee Website.pdf
Additional Benefits for Employee Website.pdfAdditional Benefits for Employee Website.pdf
Additional Benefits for Employee Website.pdf
 
Instructions for Submissions thorugh G- Classroom.pptx
Instructions for Submissions thorugh G- Classroom.pptxInstructions for Submissions thorugh G- Classroom.pptx
Instructions for Submissions thorugh G- Classroom.pptx
 
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
 
Introduction to AI for Nonprofits with Tapp Network
Introduction to AI for Nonprofits with Tapp NetworkIntroduction to AI for Nonprofits with Tapp Network
Introduction to AI for Nonprofits with Tapp Network
 
special B.ed 2nd year old paper_20240531.pdf
special B.ed 2nd year old paper_20240531.pdfspecial B.ed 2nd year old paper_20240531.pdf
special B.ed 2nd year old paper_20240531.pdf
 
How to Make a Field invisible in Odoo 17
How to Make a Field invisible in Odoo 17How to Make a Field invisible in Odoo 17
How to Make a Field invisible in Odoo 17
 
Unit 2- Research Aptitude (UGC NET Paper I).pdf
Unit 2- Research Aptitude (UGC NET Paper I).pdfUnit 2- Research Aptitude (UGC NET Paper I).pdf
Unit 2- Research Aptitude (UGC NET Paper I).pdf
 
678020731-Sumas-y-Restas-Para-Colorear.pdf
678020731-Sumas-y-Restas-Para-Colorear.pdf678020731-Sumas-y-Restas-Para-Colorear.pdf
678020731-Sumas-y-Restas-Para-Colorear.pdf
 
Francesca Gottschalk - How can education support child empowerment.pptx
Francesca Gottschalk - How can education support child empowerment.pptxFrancesca Gottschalk - How can education support child empowerment.pptx
Francesca Gottschalk - How can education support child empowerment.pptx
 
2024.06.01 Introducing a competency framework for languag learning materials ...
2024.06.01 Introducing a competency framework for languag learning materials ...2024.06.01 Introducing a competency framework for languag learning materials ...
2024.06.01 Introducing a competency framework for languag learning materials ...
 
Model Attribute Check Company Auto Property
Model Attribute  Check Company Auto PropertyModel Attribute  Check Company Auto Property
Model Attribute Check Company Auto Property
 
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
 

CS101- Introduction to Computing- Lecture 41

  • 1. 1 CS101 Introduction to Computing Lecture 41Images & Animation (Web Development Lecture 14)
  • 2. 2 During the last lecture we discussed String Manipulation • We became familiar with methods used for manipulating strings • We became able to solve simple problems involving strings
  • 3. 3 String Manipulation in JavaScript • In addition to the concatenation operator (+) JavaScript supports several advanced string operations as well • Notationaly, these functions are accessed by referring to various methods of the String object • Moreover, this object also contains the ‘length’ property
  • 4. 4 String Methods FORMAT string.methodName( ) EXAMPLE: name = “Bhola” ; document.write( name.toUpperCase( ) ) ; document.write( name.bold( ) ) ; BHOLABhola
  • 5. 5 Two Types of String Methods 1. HTML Shortcuts 2. All Others
  • 6. 6 String Methods: HTML Shortcuts bold( ) italics( ) strike( ) sub( ) sup( ) big( ) small( ) fontsize( n ) fixed( ) fontcolor( color ) link( URL )
  • 7. 7 String Methods: All Others split( delimiter ) toLowerCase( ) toUpperCase( ) charAt( n ) substring( n, m ) indexOf( substring, n ) lastIndexOf( substring, n )
  • 8. 8 Automatic Conversion to Strings • Whenever a non-string is used where JavaScript is expecting a string, it converts that non-string into a string • Example: – The document.write( ) method expects a string (or several strings, separated by commas) as its argument – When a number or a Boolean is passed as an argument to this method, JavaScript automatically converts it into a string before writing it onto the document
  • 9. 9 The ‘+’ Operator • When ‘+’ is used with numeric operands, it adds them • When it is used with string operands, it concatenates them • When one operand is a string, and the other is not, the non-string will first be converted to a string and then the two strings will be concatenated
  • 10. 10 Strings In Mathematical Expressions When a string is used in a mathematical context, if appropriate, JavaScript first converts it into a number. Otherwise, a “NaN” is the result document.write( "2" * Math.PI ) ; document.write( "Yes" ^ 43 ) ; NaN 6.283185307179586
  • 11. 11 The ‘toString’ Method Explicit conversion to a string EXAMPLE: Convert 100.553478 into a currency format a = 100.553478 ; b = a.toString( ) ; decimalPos = b.indexOf( ".", 0 ) ; c = b.substring( 0, decimalPos + 3 ) ; document.write( c ) ; 100.55
  • 12. 12 Conversion from Strings parseInt( ) and parseFloat( ) methods
  • 13. 13 Today’s Goal (Images & Animation) • To become able to add and manipulate images and simple animations to a Web page
  • 14. 14 Images in HTML • It is quite straight forward to include gif and jpg images in an html Web page using the <IMG> tag • Format: <IMG src=URL, alt=text height=pixels width=pixels align="bottom|middle|top"> • Plea: Don’t use images just for the sake of it!
  • 15. 15
  • 16. 16 <HTML><HEAD> <TITLE>Image Demo</TITLE> </HEAD><BODY> <H1>Image Demo</H1> Here is an image <IMG src="die5.gif"> <IMG src="die5.gif" height="63" width="126"> <P> Here is another <IMG align="middle" src= "http://www.vu.edu.pk/images/logo/logotop.jpg"> </BODY></HTML>
  • 17. 17 Images in JavaScript • Images in JavaScript can be manipulated in many ways using the built-in object Image • Properties: name, border, complete, height, width, hspace, vspace, lowsrc, src • Methods: None • Event handlers: onAbort, onError, onLoad, etc.
  • 18. 18 Image Preloading • The primary use for an Image object is to download an image into the cache before it is actually needed for display • This technique can be used to create smooth animations or to display one of several images based on the requirement
  • 19. 19 The Image Pre-Loading Process 1. An instance of the Image object is created using the new keyword 2. The src property of this instance is set equal to the filename of the image to be pre-loaded 3. That step starts the down-loading of the image into the cache without actually displaying it 4. When a pre-loaded image is required to be displayed, the src property of the displayed image is set to the src property of the pre- fetched image
  • 20. 20 Let us revisit an example that we first saw in lecture 35
  • 21. 21 * * * *
  • 22. 22
  • 25. 25 <IMG name="die" src="die6.gif"> <FORM> <INPUT type="button" value="Roll the Die" onClick="rollDie( )"> </FORM>
  • 26. 26 dieImg = new Array( 7 ) ; for( k = 1; k < 7; k = k + 1 ) { //Preload images dieImg[ k ] = new Image( ) ; dieImg[ k ].src = "die" + k + ".gif" ; } function rollDie( ) { dieN = Math.ceil( 6 * Math.random( ) ) ; document.die.src = dieImg[ dieN ].src ; }
  • 27. 27 Another Example • Develop a Web page that displays six thumbnail images and a main image • The main image should change to a larger version of the thumbnail as soon as the mouse moves over on a thumbnail image
  • 28. 28
  • 30. 30 dieImg = new Array( 7 ) ; for( k = 1; k < 7; k = k + 1 ) { // Preload images dieImg[ k ] = new Image( ) ; dieImg[ k ].src = "die" + k + ".gif" ; }
  • 31. 31 <IMG name="big" src="die6.gif" width="252" height="252"><P> <IMG src="die1.gif" width="63" height="63" onMouseOver= "document.big.src=dieImg[ 1 ].src"> … … <IMG src="die6.gif" width="63" height="63" onMouseOver= "document.big.src=dieImg[ 6 ].src">
  • 32. 32 Where Else Can We Use This? • Automobile Web site • ???
  • 33. 33 Animation Example 1 • Take 16 images and cycle through them to create an animation effect
  • 34. 34 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
  • 35. 35
  • 37. 37 <CENTER> <IMG name="circle" src="circle1.gif" onLoad="setTimeout( 'circulate( )', gap )"> </CENTER> setTimeout( ) executes circulate( ) once after a delay of gap milliseconds
  • 38. 38 gap = 100 ; imageN = 1 ; circImg = new Array( 17 ) ; for( k = 1; k < 17; k = k + 1 ) { // Preload images circImg[ k ] = new Image( ) ; circImg[ k ].src = "circle" + k + ".gif" ; }
  • 39. 39 function circulate( ) { document.circle.src = circImg[ imageN ].src ; imageN = imageN + 1 ; if( imageN > 16 ) imageN = 1 ; }
  • 40. 40
  • 41. 41 Animated Gifs • We could have saved the 16 gif images of the previous example in a single file in the form of an animated gif, and then used it in a regular <IMG> tag to display a moving image • However, JavaScript provides better control over the sequencing and the gap between the individual images
  • 42. 42 Animation Example 2 • Take 16 images and cycle through them to create an animation effect • Provide buttons to slow down or speed up the animation
  • 43. 43
  • 45. 45 <CENTER> <IMG name="circle" src="circle1.gif" onLoad="setTimeout( 'circulate( )', gap )"> </CENTER> <FORM> <INPUT type="button" value="Slow Down" onClick="slowDown( )"> <INPUT type="button" value="Speed Up" onClick="speedUp( )"> </FORM>
  • 46. 46 gap = 100 ; imageN = 1 ; circImg = new Array( 17 ) ; for( k = 1; k < 17; k = k + 1 ) { // Preload images circImg[ k ] = new Image( ) ; circImg[ k ].src = "circle" + k + ".gif" ; } No change
  • 47. 47 function circulate( ) { document.circle.src = circImg[ imageN ].src ; imageN = imageN + 1 ; if( imageN > 16 ) imageN = 1 ; } No change
  • 48. 48 function slowDown( ) { gap = gap + 20 ; if( gap > 4000 ) gap = 4000 ; } function speedUp( ) { gap = gap - 20 ; if( gap < 0 ) gap = 0 ; } Two new functions
  • 49. 49
  • 50. 50 Flash Animation • Designed for 2-D animations, but can be used for storing static vector-images as well • A special program (called a plug-in) is required to view Flash files in a Web browser • Can be used to design complete, animated Web sites with hardly any HTML in it • Binary-file storage
  • 51. 51 Structured Vector Graphics • New format; may become more popular than Flash • Plug-in required • Text-file storage; search engine friendly
  • 52. 52 During Today’s Lecture … • We became able to add and manipulate images and simple animations to a Web page
  • 53. 53 Our 15th & Final Web Dev Lecture: (Programming Methodology) • To understand effective programming practices that result in the development of correct programs with minimum effort • To become familiar with simple debugging techniques