HTML
HTML
T
M
L
5
ANKIT SINGH
ANKIT SINGH
HTML Introduction
What is HTML?
HTML is a markup language for describing web documents (web pages).
ANKIT SINGH
Example Explained:
The text between <head> and </head> provides information about the
document
The text between <title> and </title> provides a title for the document
The text between <body> and </body> describes the visible page
content
ANKIT SINGH
<TITLE>
<MEAT>
<BASE>
<STYLE>
<LINK>
<SCRIPT>
<NOSCRIPT>
ANKIT SINGH
ANKIT SINGH
<HEAD>
<TITLE>The Style Tag Example</TITLE>
<style>
h1 {
color: red;
font-size: 14px;
}
P{
Font-style:italic;
}
</style>
</HEAD>
<BODY>
<h1>The Style using for style Tag</h1>
<p>Its Provides Online Booking</p>
</BODY>
</HTML>
ANKIT SINGH
The alert ( ) function code displays the message, Welcome John when the OK
button in the prompt is clicked.
ANKIT SINGH
Applying Headings
The HTML allows SIX levels of headings, ranging from <H1> to <H6> The <H1> tag
is used to define the topmost heading, whereas the <H6> tag is used to define the
lowest-level heading
Example:<HTML>
<HEAD></HEAD>
<BODY>
<H1>This Example is Heading 1 </H1>
<H2> This Example is Heading 2 </H2>
<H6> This Example is Heading 3 </H6>
</BODY>
</HTML>
ANKIT SINGH
Adding paragraphs
You can use the new paragraphs in a HTML
<p>
<DETAILS>
<SUMMARY>
<P>
The <p> tag add a new paragrphs in the HTML Document.the <p>
Tag is a container the browsers automatically add one line space before and after
the content.
Example:<BODY>
<P>Welcome to the first website </P>
<p>Created by Mr. Ankit singh</P>
</BODY>
<DETAILS>
The additional content that a user can view or hide as per requirement to be
used details tag in your HTML document.
<BODY>
ANKIT SINGH
10
<DETAILS>
<P> We provide Computer Education for all type </P>
</DETAILS>
</BODY>
<SUMMARY>
A heading for the <DETAILS> TAG Users can click this heading to view or hide
the details.
Example:<BODY>
<DETAILS>
<SUMMARY>Categories of Computer Education</SUMMARY>
<P>ADCA,DCA,BASIC,TALLY,HTML,JAVA,C,C++,C#,COREL DROW,PHOTO
SHOP</P>
</DETAILS>
</BODY>
ANKIT SINGH
11
Defining a Layout
The layout of a Web page and separate individual elements or content should be
displayed on the Web page.
<DIV>
<SPAN>
<DIV>
The <DIV>tag is used to define a section in a document. It is used to group of
sections as blocks
<SPAN>
The <span> tag enables you to group and apply styles to inline elements. The tag is
dependent on the style attribute on a particular word and line.
<BODY>
<p>The demo of the <span style=color:blue;font-size:16px;> sapn </span>
tag</p>
</BODY>
ANKIT SINGH
12
<B>
<I>
<U>
<LI>
<BR>
<HR>
<B>
The <B> tag is used to bold font face.
<BODY>
<B>You can Read online HTML Code</B>
</BODY>
<I>
The <I> tag is used to Italic font face.
<BODY>
<I> You can Read online HTML Code </I>
</BODY>
ANKIT SINGH
13
<U>
The <U> tag is used to underline the text
<BODY>
<U> You can Read online HTML Code </U>
</BODY>
<LI>
The <LI> tag is used to create a lists. In HTML Document represented with special set
of tags.
ANKIT SINGH
14
<BODY>
<ul><li>HTML </li>
<li>JAVA</li>
<li>C#</li></ul>
</BODY>
Definition list
The definition tag used one or more terms definition are to be included in an
HTML document. Its represent by the <DL> tag. And this tag to comprises two
other tags <DT> and <DD>
<BODY>
<DL>
<DT>Title1</DT><DD>This is a first definition</DD>
<DT>Title2</DT><DD>This is a second definition </DD>
</DL>
</BODY>
<BR>
The <BR> tag is used to break of the line code.
<BODY>
Welcome to the HTML<br> Book To Create by Ankit singh
</BODY>
ANKIT SINGH
15
<HR>
The <HR> tag is used to create a horizontal line
<BODY>
Welcome to the HTML<br><hr>
Book To Create by Ankit singh
</BODY>
Adding Images
The images are used to create more interesting as ideas are well communication
with images and graphics.
GIF:-
JPEG:ANKIT SINGH
16
Joint Photographic Experts Group The format is used when the image is a
photograph medical image or complex photographic
PNG:-
17
Alt
Height
Width
href the href attribute specifies the URL to connect the document
using hyperlink
<AUDIO>
<VIDEO>
<AUDIO>
The <audio>tag provide adding a audio in a web page.
<AUDIO controls=controls src=audio1.mp3>Your browser does not
support this audio format.</AUDIO>
<VIDEO>
The <video> tag is provide displaying a video on a web page.
ANKIT SINGH
18
<METER>
<PROGRESS>
<METER>
The <meter> tag a scalar measurement within a used to display disk usage.
<P>Display a meter</p>
<METER value=4 min=0 max=10></METER>
ANKIT SINGH
19
<PROGRESS>
The <progress> tag is used to display the progress of the task.
Progress of a task:
<PROGRESS value=12 max=100></PROGRESS>
Semantic tags
<HGROUP>
<ARTICLE>
<ASIDE>
<HEADER>
<FOOTER>
<NAV>
<FIGURE>
<hgroup>
You need to group related heading and sub heading than you used to<hgroup>
tag.
<HDROUP><H1>Book your course</H1>
<H2>Rating of the course</H2>
<H6>shot Course</H6></HGROUP>
ANKIT SINGH
20
<ARTICLE>
The <ARTICLE> tag an independent or a self-contained content
<ARTICLE><H1>Book your course</H1>
<p>This Course is specifically designed to provide details about your
course</p></ARTICLE>
<ASIDE>
the <aside> tag is used the write a note or a tip
<ASIDE><P>Get discounts on book course today</P></ASIDE>
<HEADER>
The <HEADER> tag is used to defined website heading you can used multiple
<HEADER> tag.
<HEADER><H1>Book Your course </H1>
<p>An easy way of booking your course</p> </HEADER>
<FOOTER>
The <FOOTER> tag is used to add a footer in your web page.
<FOOTER>Author: Ankit singh</FOOETR>
ANKIT SINGH
21
<NAV>
The <Nav> tag is used to group of link created by using <A> tag.
<NAV>
<A href=Course>Course</A>|
<A href=About>About Your Course</A>|
<A href=Booking>Booking</A></NAV>
<FIGURE>
The <FIGURE> tag is used to self-contained such as images diagrams photo.
<FIGURE><FIGCAPTION>HD Image</FIGCAPTION><IMG
src=localimg.jpg alt=image width300 height=400></FIGURE>
ANKIT SINGH
22
Inline style
Internal style sheet
External style sheet
Inline Style
Inline style is use to particular paragraph tags the Inline style are attached directly with
the HTML tag.
<HTML>
<BODY><P style=font-size: 24px; color: red;>Course book of 2nd July
</p><p>Compare the course from other course</p></BODY>
</HTML>
ANKIT SINGH
23
<html>
<head>
<style type=text/css>
P{color:red; font-size:20px; font-style:italic;}
</style>
</head>
<body>
<p>Welcome to the first internal style created by Ankit singh</p>
<p>compare to the other book</p>
</body>
</html>
P
{
color:red; font-size:20px; font-style:italic;
}
H1
{
color:blue;
}
Save the code mystyle.css
<html>
<head>
</head>
<link rel="stylesheet" type="text/css" href="mystyle.css">
ANKIT SINGH
24
<body>
<h1>Welcome to the first internal style created by Ankit singh</h1>
<p>compare to the other book</p>
</body>
</html>
CSS SELECTORS
To use a style any tag and you uniquely identified one than you can used CSS Selector
user defined CSS selectors ID and Class selector
ANKIT SINGH
25
}
</STYLE>
</HEAD>
<BODY>
<p id=pname>Welcome to the HTML Book</p>
<p>Book Reading facility </p>
</BODY>
</HTML>
ANKIT SINGH
26
color:red;
font-weight:bolt;
}
</style>
</head>
<body>
<h1>Welcome to the Ankit singh website</h1>
<h2>this site is very user friendly</h2>
<p>this site is gives information of all the HTML tag</p>
</body>
</html>
ANKIT SINGH
27
</style>
</head>
<body>
<h1 class=name>Welcome to the Ankit singh website</h1>
<h2 class=name>this site is very user friendly</h2>
<p class=name>this site is gives information of all the HTML tag</p>
</body>
</html>
Font
Text
Link
List
Background
Font
Font properties is used to customize the text is display
P
{
Font-family: Haettenschweiler;
Font-size:20px;
}
h1
{
Font-variant:small-caps;
ANKIT SINGH
28
Font-style:italic;
}
Valid Values
PROPERTY
Definition
Sample Usage
Font-Family
Different font
types,such as times
new roman, courier,
verdana, Helvetica,
arial, and san serif
{font-family: arial,
times roman; }
Font-Size
Font-Style
Normal, italic, or
oblique
{font-size:12px: }
{ font- size: 100% ; }
{ font- size:xsmall; }
{ font -size:xlarge; }
{ font style :
italic ; }
Font-Variant
Is used to specify
whether a text
should be displayed
in small copy font or
in a normal font.
Normal or smallcaps
{ font -variant :
small- caps : }
Font-Weight
Normal or bolder
decimal values from
100 to 900
{ font weight :
bold ;}
{ font- weight :
600 ; }
Font
Font-style||
font variant||
font weight||
font size|| fontfamily
Text
Text properties Is used to change the colour alignment of text element.
P
{
letter-spacing:2px;
line-height:12px;
}
h1
{
ANKIT SINGH
29
color: red;
text-align: center;
}
Property
Definition
Valid Values
Sample Usage
text-align
Left | right |
Center | Justify
Text-indent
Length in pixels |
Percentage
{text
intent:25px; }
{text indent:5#;
normal | number
length
in pixels
|
percentage
ltr | rtl
line-height
Direction
VerticalAlign
Property
(sub | super
| baseline) ||
Length in pixels ||
percentage
{line-hight:10pt; }
{lineheight:100#; }
{line height:
normal;
}
{direction: rtl; }
{vertical-align: sub ;
}
{vertical-align:50#;
}
{vertical-align: 30px; }
{vertical-align:20px; }
Definition
Valid Values
Color
text-decoration
{color: red ; }
{color: # 00ff00;}
color:rgb(0,0,255 ) ;
{textDecoration:
underline;
}
texttransform
Capitalize |
Uppercase |
lowercase | none
{text- .
Transform:
uppercase;
}
letter-
normal | length
{letter-spacing:4pt;
ANKIT SINGH
Sample Usage
30
spacing
word spacing
where, length
specifies
an extra space
between
Characters. Negative
Values are also
allowed.
normal | length
}
{letter-spacing:-2pt;
}`
{vord-spacing:3px ;
}
Link
Link properties is used to customize the link in the HTML document.
Link: An unvisited link
Visited: A visited link
hover: this is work mouse is placed or moved over
active: A link as it appears it is clicked
<style>
a: link
{
color:blue;
}
a:visited
{
color:red;
}
a: hover
{
color:pink;
}
a:active
{
color:green;
}
</style>
List
list properties is used to look of the order and unordered HTML lists.
Ul
{
list-style-type:square;
list-style-position: inside;
ANKIT SINGH
31
Property
its--style-position
Definition
Valid Values
Sample
usage
is used to specify
the position of listitem markers
according to the
content flow:
inside outside
(List-styleposition:
inside :)
Disk I circle I
square I decimal
I
Lower-roman |
Upper-roman |
Lower-roman |
Upper-alpha |
Lower-Latin |
Upper-lain |none|
urn | none
{ list
styletype: upperalpha. }
its-style-type
is used to specify
the type of the listitem markers.
ist-style-image
is used to specify an
image on list item
markers.
ist style
type || position ||
image
( list style_
image : urn
(plus.gif ) :
)
{ list style
:
Square
outside
url (plus . gif
);}
Background
Background properties is used to specify the background color image of the HTML
element.
<style>
Body
{
Background-color:lavender;
}
</style>
Property
Definition
Valid Values
ANKIT SINGH
Sample Usage
32
Background color
Is used to set
background color of
an HTML element.
Color \ transparent
(background
color : yellow ; )
Background - image
Is used to set
background image
of an HTML element.
None \ url
(background
image : url ( img .
gif ) ; )
Background
Background color \
background - image
(background : green
url ( img . gif ) } ;
Grouping Style
Style are uses to apply same style more than one selector by combining them.
H1,p
{
color:red;
}
Nesting Style
Nesting style used to style element inside the other element style this style used to
better look and feel.by using the class and ID selector.
Selector
Element1>element2
Examp
le
Description
Div>p
Div p
Element1 +
element
Div+p
element 1 +
element 2
div+p
Selects the
<p> element that is
placed immediately after the <DIV>
element.
element 1 element
2
div p
Selects all
the <p> elements that follow the
Element1 element2
ANKIT SINGH
33
<DIV>
Element
Position
Float
Position
The position property is used to set the position an element on a web page.
Positioning Method
Description
Static
Fixed
Relative
Absolute
Property
Definition
Valid values
Sample Usage
Auto | length|
(Bottom: 5px ;)
Bottom
Top
Auto| length|
percentage
(Top: 5px ;)
Left
Auto | length|
percentage
Auto | length|
percentage
(Left: 5px ;)
Static |
absolute | fixed
| relative
(Position:
static ;)
Right
Position
left margin
element.
right margin
element.
ANKIT SINGH
(Right:
5px ;)
34
Float
the float property is used to place the HTML element to left or right margin.
float: left | right | none
<html>
<head>
<style>
img
{
float:left;
}
.auto
{
clear:both;
}
</style>
</head>
<body>
<img src=hotel1.jpg height=300 width=500></img>
ANKIT SINGH
35
The hotels reception is open 24 hours a day and offers bookingservices for
guided tours to Monte Carlo, Saint Paul de Venceand excursions by
boat towards Antibes and Cannes or to the nearby Isola 2000 ski resorts.
</p>
</body>
</html>
Clear
The clear property is used to turn off the float effect on HTML element.
Applying Transitions
You want to change the color of the HTML element from red to black in the event is
mouse hover event the CSS transition provide a way to moderately change the HTML
element from one position to another.
<html>
<head>
<style>
Div
{
width:200px;
ANKIT SINGH
36
height:200px;
background:red;
-webkit-transition:width 4s;
-o-transition:width 4s;
}
div:hover
{
width:400px;
}
</style>
</head>
<body>
<div></div>
</body>
</html>
ANKIT SINGH
37
Applying Animations
To apply animation effects on HTML elements. You can create an animation that will
increase the size of the element when user clicks.
<!DOCTYPE html>
<html>
<head>
<style>
div {
width: 100px;
height: 100px;
background-color: red;
-webkit-animation-name: example; /* Chrome, Safari, Opera */
-webkit-animation-duration: 4s; /* Chrome, Safari, Opera */
animation-name: example;
animation-duration: 4s;
}
/* Chrome, Safari, Opera */
@-webkit-keyframes example {
from {background-color: red;}
to {background-color: yellow;}
}
/* Standard syntax */
@keyframes example {
from {background-color: red;}
to {background-color: yellow;}
}
</style>
</head>
<body>
ANKIT SINGH
38
Applying transformations
You want to rotate a cube having different pictures on its curves. CSS provides the
functionality of transformations to modify the HTML element.
2D transforms
2d transforms you can apply various transformations such as rotations or translations on
HTML element.
<html>
<head>
<style>
div
{
width:200px;
height:100px;
background-color:red;
transform:rotate(60deg);
-webkit-transform:rotate(60deg);
}
</style>
</head>
<body>
<div></div>
</body>
</html>
ANKIT SINGH
39
3D
HTML element by using 3D transforms. The using transform methods
RotateX() Rotate element at given degree around X-axis.
RotateY() Rotate element at given degree around Y-axis.
Project Time
Home style
ANKIT SINGH
40
Home.Html
<html>
<head>
<title>
UpComingMovies
</title>
<link rel="shortcut icon" href="movie_run.png">
ANKIT SINGH
41
ANKIT SINGH
42
<A href="Onlinebooking.html">OnlineBooking</A>
</nav>
</div>
<h4>Currently, showing...</h4>
<img src="207.jpg" width="222" height="200">
<img src="206.jpg" width="222" height="200">
<img src="204.jpg" width="222" height="200">
<img src="203.jpg" width="222" height="200">
ANKIT SINGH
43
ANKIT SINGH
44
ANKIT SINGH
45
</html>
ANKIT SINGH
46
Creating Tables
If you want to show the result information on your website than you need to creating a
well structured of table on a webpage using tables. Tables represent complex information
in a simple and easy to understand manner. By using tables
ANKIT SINGH
47
Creating Row
The Adding rows in the table using <tr> tag. The contents place between <tr>and </tr>
tag
Creating Columns
The adding the columns to the <td> tag the <td> tags are uses within <tr>
and </tr> tags.
<html>
<body>
<table border="2">
<tbody>
<tr><th>Name</th>
<th><ul>Login Id</th>
<th>Course Name</th>
<th>Marks</th></tr>
<tr class="alt"><td>steve</td>
<td>01234</td>
<td>My sql 5 Developer certified professional Exam,part I </td>
<td>92</td></td>
<tr><td>John</td>
<td>01235</td>
<td>Mysql 5 Developer Certified Professional Exam, part II</td>
<td>85</td>
<tr class="alt"><td>Joseph</td>
<td>01236</td>
<td>Mysql 5 Database Administrator Certified Professional Exam, Part
I</td>
<td>98</td>
<tr ><td>Michel</td>
<td>01237</td>
ANKIT SINGH
48
ANKIT SINGH
49
Rowspan Example:
<html>
ANKIT SINGH
50
<body>
<table border="2">
<tbody>
<tr><th rowspan="6"><center>Top Three
Performers</center></th></tr>
<tr><th>Name</th>
<th><ul>Login Id</th>
<th>Coutse Name</th>
<th>Marks</th></tr>
<tr class="alt"><td>steve</td>
<td>01234</td>
<td>My sql 5 Developer certified professional Exam,part I </td>
<td>92</td></td>
<tr><td>John</td>
<td>01235</td>
<td>Mysql 5 Developer Certified Professional Exam, part II</td>
<td>85</td>
<tr class="alt"><td>Joseph</td>
<td>01236</td>
<td>Mysql 5 Database Administrator Certified Professional Exam, Part
I</td>
<td>98</td>
<tr ><td>Michel</td>
<td>01237</td>
<td>Mysql 5 Database Administrator Certified Professional Exam, part
II</td>
<td>25</td>
</tr>
</tbody>
</body>
</html>
ANKIT SINGH
51
ANKIT SINGH
52
<td>01236</td>
<td>Mysql 5 Database Administrator Certified Professional Exam, Part
I</td>
<td>98</td>
<tr ><td>Michel</td>
<td>01237</td>
<td>Mysql 5 Database Administrator Certified Professional Exam, part
II</td>
<td>25</td>
</tr>
</body>
</html>
<html>
<head>
<style>
th
{
font-size:18px;
text-align:center;
padding-top:3px;
background-color:#BDB76B;
color:#006400;
ANKIT SINGH
53
}
caption
{
font-size:35px;
color:black;
}
td
{
font-size:15px;
border:1px solid #008B8B;
padding:3px;
background-color:khaki;
}
tr.alt td
{
color:#F0E68C;
background-color:#B22222;
}
</style>
</head>
<body>
<table border="2">
<caption>Test Results</caption>
<tr><th colspan="4"><center>Top Three
Performers</center></th></tr>
<tr><th>Name</th>
<th><ul>Login Id</th>
<th>Coutse Name</th>
<th>Marks</th></tr>
<tr class="alt"><td>steve</td>
<td>01234</td>
<td>My sql 5 Developer certified professional Exam,part I </td>
<td>92</td></td>
ANKIT SINGH
54
<tr><td>John</td>
<td>01235</td>
<td>Mysql 5 Developer Certified Professional Exam, part II</td>
<td>85</td>
<tr class="alt"><td>Joseph</td>
<td>01236</td>
<td>Mysql 5 Database Administrator Certified Professional Exam, Part
I</td>
<td>98</td>
<tr ><td>Michel</td>
<td>01237</td>
<td>Mysql 5 Database Administrator Certified Professional Exam, part
II</td>
<td>25</td>
</tr>
</body>
</html>
ANKIT SINGH
55
ANKIT SINGH
56
ANKIT SINGH
57
Home.HTML page
<html>
<body>
ANKIT SINGH
58
NAV.HTML
<html>
<head>
<style>
body
{background-color:#00C0F3;}
ul {margin:0; padding:0;list-style:none width:350px}
ul li a{display:block; text-decoration:none; color Black; background:
#B3ECFC; padding: 5px border:1px solid #ccc; border-bottom:0;}
ul{margin:0;padding:0;list-style:none;width:320px;}
li:hover ul{display: block;}
a:hover{background-color:#5E9DC9;}
</style>
</head>
<body>
<ul><li><A href="E:\book niit\new folder\HTML5 Media.pdf"
target="contentFrame">HTML</A></li>
<li><A href="E:\book niit\new folder\"
target="contantFrame">SQL</A></li>
<li><a href="">ASP.NET</a></li><ul>
</body>
ANKIT SINGH
59
</html>
HEAD NAV.HTML
<html>
<head>
<style>
body
{background-color:#00C0F3;}
h1{color:white;font-size:45;}
</style>
</head>
<body>
<center>
<h1 >Learn HTML</h1>
</body>
</html>
ANKIT SINGH
60
ANKIT SINGH
61
Project Time
Home style
ANKIT SINGH
62
body{background-color:#D51165; backgound-image:
src("D:\ankit\3D\70.jpg"); background-repeat: repeat-x;}
ANKIT SINGH
63
Ucm style
<style>
table{position:absolute; top:140px; left:10px; right:120px; border:solid
4px green;}
td{text-align:center;border:solid 1px green; padding:3px;}
th{background-color:green; color:white;border:solid 1px green;}
tr{color:green}
</style>
Ucm.HTML
<html>
<head>
<title>
UpComingMovies
</title>
<link rel="shortcut icon" href="movie_run.png">
<link type="text/css" rel="stylesheet" href="homestyle.css"/>
<link type="text/css" rel="stylesheet" href="ucm.css"/>
<script type="text/javascript">
function onlinebooking()
{
ANKIT SINGH
64
<div id="topnav" style="float:left; width:960px; height: 20px; wordspacing: 15px; font-size: 90%; pading-left:60px; padding-top: 6px;
white-space: nowrap; text-align:left; background-color: black;">
<nav>
<A href="homepage.html">Home</A>|
<A href="aboutus.html">AboutUs</A>|
<A href="contactus.html">ContactUS</A>|
<A href="UpComingMovie.html">UpcomingMovies</A>|
<A href="Onlinebooking.html">OnlineBooking</A>
</nav>
ANKIT SINGH
65
</div>
ANKIT SINGH
66
<td>19 Jan,2015</td>
<td>INDIA</td>
<td><a href="">BookYourShow</a></td></tr>
<tr><td rowspan="3">Romantic</td>
<td>A Walk to remember-II</td>
<td>Ellen page</td>
<td>Rechel Wood</td>
<td>Victoria</td>
<td>Freddie Highmoree</td>
<td>27 Feb, 2013</td>
<td>india</td>
<td><a href="">BookYourShow</a></td></tr>
<tr><td>Twilight Saga</td>
<td>patrick</td>
<td>Wood A.Han</td>
<td>Victoria</td>
<td>Victoria A.</td>
<td>17 May,2015</td>
<td>india</td>
<td><a href="">bookyourshow</a></td></tr>
<tr><td>if only_ii</td>
<td>Ellina smith</td>
<td>Rachel Wood</td>
<td></td>
<td>Robert vann</td>
<td>23 june, 2015</td>
<td>a</td>
ANKIT SINGH
67
<td><a href="">bookyourshow</a></td></tr>
<tr><td rowspan="4">Action</td>
<td>star wars</td>
<td>robert</td>
<td>logan lerman</td>
<td></td>
<td>ariana grande</td>
<td>23 june, 2015</td>
<td>india</td>
<td><a href="">bookyourshow</a></td></tr>
<tr><td>man of steel</td>
<td>patrick</td>
<td>rachel wood</td>
<td></td>
<td>victoria</td>
<td>17 may,2015</td>
<td>india</td>
<td><a href="">bookyourshow<a></td></tr>
<tr><td>area 52</td>
<td>dianna</td>
<td>alice</td>
<td></td>
<td>robert s. vann</td>
<td>28 sep, 2015</td>
<td>a</td>
<td><a href="">bookyourshow</a></td></tr>
<tr><td>2 guns</td>
ANKIT SINGH
68
<td>illiana</td>
<td>john park</td>
<td>ankit</td>
<td>josh hutcherson</td>
<td>23 oct, 2015</td>
<td>india</td>
<td><a href="">bookyourshow</a></td></tr></table></div>
</body>
</html>
ANKIT SINGH
69
ANKIT SINGH
70
Scripting
Types of Scripting
Create a dynamic and interactive web page you need to incorporate a block of code the
script can be executed either by the web browser. The requests is send to a computer
that is placed at a different location on the World Wide Web. Computer on which the
browser is running is known as the client.
Client-side scripting
Server-side scripting
Client-side Scripting
Client side scripting refers to the scripts that are executed at the client side by the web
browser running on the users computer some of the languages used for creating client
side scripts are client side JavaScript (CSJS)
Server-side Scripting
Server-side scripting refers to the scripts that are executed by the web server on the
basis of the users request. Some of the languages used for creating server-side scripting
are server-side JavaScript (SSJS)
ANKIT SINGH
71
Benefits of javaScript
Handle events java Script can be used to execute functions whenever an event
is triggered
Gather browser information java script can be used to gather browser
information such as the browser name and version.
Manipulate cookies java script can be used to access and store user information
such as client preferences and authentication information of a client computer in
the form of cookies.
Implementing JavaScript
JavaScript is one of the most popular scripting languages. It can be used to provide
functionality to a web page.
Two type of implement scripting in a web page
A script can be embedded directly into a web page by writing the javaScript code inside
the <script> tag. Or writing the JavaScript code in an external JavaScript (.js) file.
LEO
Mobile\n+2.
LEO
ANKIT SINGH
72
<h1>By Products</h1>
<SCRIPT type=text/javascript src=sale.js>
</SCRIPT>
</body>
</html>
Save the file as home.html
Rules and Conventions Used in JavaScript
Defining Variables
A variables is a named location in memory that is used to store a value.
Quantity=5
Price=250
Declaring a variable
The using a variable in your program you should declare it first. JavaScript allow to
declare a variable by using the var keyword.
var var_name;
var employeeName ;
ANKIT SINGH
73
employeeName=Peter;
using Operators
<html>
<body>
<SCRIPT type=text/javascript>
var employeeName;
var basicSalary;
var othersAllowance;
var TotalSalary;
employeeName=peter;
basicSalary=20000;
otherallowance=1000;
TotalSalary=basicSalary+otherAllowance;
</SCRIPT>
</body>
</html>
Operator Categories
Arithmetic Operators
Assignment Operator
Arithmetic Assignment Operators
Comparison Operators
Logical Operators
ANKIT SINGH
74
Arithmetic Operators
Arithmetic operators are used to perform arithmetic operations on variable and literals.
Assignment Operator
An assignment operator (=) is used to assign a value or a result of an expression to a
variable.
Arithmetic Assignment Operators
Arithmetic assignment operators are used to perform arithmetic operations and assign
the value to the variable a the left side of the operator
ANKIT SINGH
75
Comparison Operators
Comparison operators are used to compare two value and perform an action on the basis
of the comparison.
ANKIT SINGH
76
Logical Operators
Logical operators are used to evaluate complex expressions in which there is a need to
evaluate a single expression or multiple expressions to assess the result.
Conditional Constructs
ANKIT SINGH
77
Example
var age=5;
if(age<12)
{
alert(Sorry ! this game is for children above 12 years);
}
Else
{
alert(Play the Game);
}
ANKIT SINGH
78
case ConstantExpression_2 :
//statements;
break;
case ConstantExpression_n:
//statements;
break;
default:
//statements;
break;
}
Loop Constructs
Example
<SCRIPT type=text/javascript>
var num=0;
while(num<20)
{num=num+1; alert (num);
}
</SCRIPT>
ANKIT SINGH
79
Example
<SCRIPT type=text/javascript>
var num=0;
do
{num=num+1;
alert (num);
}
while(num<20)
</SCRIPT>
ANKIT SINGH
80
The for loop allow the execution of a block of code depending on the result of the
evaluation of the text condition.
<SCRIPT type=text/javascript>
var num;
var sum=0;
for(num=100;num<200;num++)
ANKIT SINGH
81
{
Sum=sum+num;
}
alert(sum);
</SCRIPT>
Continue
The continue statement is used to skip all the subsequent instruction and take the
control back to the beginning of the loop.
while(test condition)
{
//statement1;
if(test condition1)
{
continue;
}
ANKIT SINGH
82
//statement2;
//statement3;
}
Function
Built-in functions
User-defined functions
Built-in Functions
Built-in function are ready to use as they are already coded the built-in functions
supported by JavaScript.
isNaN ()
parseInt ()
parseFloat ()
evel ()
prompt ()
confirm ()
isNaN ()
the isNaN function determines whether a parameter is not a number. The function return
true if the parameter is not a number
<html>
<body>
<SCRIPT type="text/javascript">
num1="Two thousant";num2=8000;
Result=isNaN(num1);alert(Result);
res=isNaN(num2); alert(res);
</SCRIPT>
</body>
</html>
parseInt ()
the parseInt () function parse the string parameter and return the corresponding integer.
X=5;
ANKIT SINGH
83
Y=parseInt(x);
parseFloat ()
the parseFloat () function takes a string parameter and returns a floating point number.
X=6.5;
y=parseFloat(x);
eval()
the evel () function is used to evaluate or execute a parameter if the is a expression.
<SCRIPT type=text/javascript>
var res1=0; res1=evel(5+100;
alert(res1);
</SCRIPT>
prompt ()
the prompt () function is used to display a prompt dialog box allow a user to input value.
<html>
<body>
<script>
var a,b,c;
a=parseInt(prompt("Enter number :1"));
b=parseInt(prompt("Enter number :2"));
c=a+b;
document.write(c);
</script>
</body>
</html>
ANKIT SINGH
84
confirm ()
the confirm () function is used to display a dialog box that will enable a user to verify or
accept a task. If user clicks the ok button the confirm () function return true. If the user
clicks the cancel button the confirm () function return false.
<html>
<body>
<SCRIPT type="text/javascript">
var response;
response=confirm("Do you wish to continue");
if(response==true)
{
alert("you can proceed further");
}
else
{
alert("you cannot proceed further");
}
</SCRIPT>
</body>
</html>
User-defined Functions
The user-defined function you to define your own function according to your needs.
Creating Functions
Create by function keyword
function functionName (variable1,variable2)
{
//function statement
}
A user-defined function can optionally accept a list of parameters.
ANKIT SINGH
85
Calling a Function
A function is called by using the function name .
functionName ();
<!DOCTYPE html>
<html>
<body>
<p id="demo"></p>
<script>
function myFunction(a, b) {
return a * b;
}
document.getElementById("demo").innerHTML = myFunction(4, 3);
</script>
</body>
</html>
ANKIT SINGH
86
Creating Forms
The data entered using these form elements needs to be processed further upon
submission. Every web page should respond to end user actions such as clicking
a submit button.
Designing an HTML Form
Customers to place online order with various details such as the name contact
number and address in an online form named as Order Food Online.
Create Form
If you create a form on a web page you need to <form> tag. The <form>
Tag is define a form has on opening <form> tag and closing </form> tag.
Name
Id
Action
Method
Autocomplete
Novalidate
Target
Name
The name attribute is used to specify a unique name uniquely identify a
ID
87
Action
The action attribute is used to the URL of the document assumed as the location
for the form submission.
<form action=filename or URL>
Method
The method attribute is used to be submitted to the file or the URL action
attribute.
Get
Post
Get
The get value form data to the URL of the form submission. The size of data that
can be submitted using the get method.
Post
The post value dose not append the form data to the URL of the form submitted.
A large amount of data can be sent using the post method.
Autocomplete
The autocomplete attribute is used to a form should have the autocomplete on
or off.
<form Id=fileId autocomplete=on>
Novalidate
The novalidate attribute that the date in the form should not be validate by the
browser.
<form ID=fileID novalidate>
Target
the target attribute is used to the name of thee frame or the window in which
response after submission.
<form target=_blank | _self | _parent | _top | frame_name >
ANKIT SINGH
88
Form Elements
<INPUT>
<SELECT>
<LABEL>
<FIELDSET>
<TEXTAREA>
<DATALIST>
<KEYGEN>
<OUTPUT>
<BUTTON
<INPUT>
The <INPUT> tag. Is used to input inside A form the input fields are various type
such as text box radio button or check box. Some important attributes type
value name ID autocomplete autofocus form required pattern and placeholder.
Type
The type attribute is defined the type of input field to be added on the form.
Text creates a single line text field. Type attribute is text two additional
attribute size and maxlength, the size attribute is used for limiting the
ANKIT SINGH
89
Password
The password field which will not display the characters being typed by the user.
Actual show the values for each character ****.
<input type=password name=accountpassword>
Radio
A radio button used to select one of the options from a set of given options.
<input type=radio name=rating of Hotel checked >5-start<br>
<input type=radio name=rating of hotel>budgeted
Checkbox
A checkbox is used to select one or more option from a set of given options.
ANKIT SINGH
90
Submit
A submit button is used to the form data submit to the specified location using
action attribute of the form.
Formaction
It is used to a URL the form data would be submitted the submit button is
clicked.
Formmethod
It is used to the method such as get and post the form data will be sent to the
file or URL in the action attribute of the form
Reset
A reset button clears the values entered by a user in the form fields.
<input type=reset name=reset>
URL
That is used to enter a URL of a website the value in this field is automatically
validated the form is submitted.
<input type=URL name=locator>
ANKIT SINGH
91
A field in an HTML form to accept the email address from the users.
<input type=email name=email_id>
Range
Creates a slider control to enter a numeric value within a range.
<input type=range max=50 min=10 step=5 value=10>
Date
Is used to define a date field in a HTML form.
<input type=date name=bday>
Time
Is used to define a time field in an HTML form.
<input type=time name=user_time>
Number
ANKIT SINGH
92
Tel
is used to accept a telephone number form the user.
<input type=tel name=usrtel>
Image
Is used an image to be used as a submit button. The value of the type attribute
is image
<input type=image src=img_submit.gif alt=submit width=48
height=48>
Required attribute
The required attribute is used an input field must not be left empty while
submitting the form.
<input type=text name=username required>
Placeholder
Is used to a simple value for the input filed that will be displayed until the user
enters a value
<input type=text placeholder=type your name name=fname>
ANKIT SINGH
93
Select Tag
The select tag is a container tag it create a drop-down list in the form.
Option Tag
It is always used within the <select> tag. Option tag is used to create a list of
option in the drop-down list.
Optgroup Tag
Group the related options in one group.
Disabled is used to the option group should be shown disables whan the
page load.
Label
Is used to define a label for the input fields.
For is used to bind the <label> tag with the input field same value as the
Id attribute
Textarea
ANKIT SINGH
94
Text area tag is used the user can enter a large amount of text.
Rows set the number of row of text that will be visible without scrolling
up or down in the field
Cols set the number of columns of text that will be visible without
scrolling right or left in the field.
Datalist
The datalist tag is used to create a pre-defined options for an input fields.
<input list="browsers" name="browser">
<datalist id="browsers">
<option value="Internet Explorer">
<option value="Firefox">
<option value="Chrome">
<option value="Opera">
<option value="Safari">
</datalist>
<html>
<head>
<style>
ANKIT SINGH
95
body
{
background-color:#FFEBCD;
}
.autostyle
{
color:red;
font-size:20px;
text-align:center;
}
</style>
</head>
<body>
<form action ="registration.html">
<table>
<tr class="autostyle">
<td colspan="2">OrderFoodOnline</td></tr>
<tr><td width="100%" colspan="2"></td></tr>
<tr><td><label for="name">Name:</lable></td>
<td><input type="text" name="username" Id="name"
placeholder="Enter Your Name" required></td></tr>
<tr>
<td><label for="date">Date:</label></td>
<td> <input type="date" name="date" Id="date"
required></td></tr>
<tr><td><label for="email" >Email ID: </lable></td>
<td><input type="email" name="useremail" Id="email"
placeholder="Enter Your Email Id"
ANKIT SINGH
96
Required></td></tr>
<tr>
<td><label for="Number">Contact Number</label></td>
<td><input type="tel" name="usrtel" ID="number"
placeholder="Enter Youe phone Number"
required></td></tr>
<tr><td><label for="Food">Select Food:</label></td>
<td><label for="nonveg">Non-vegetarian</label> <input
type="radio" name="food" id="nonveg">
<label for="veg">Vegetarian</label>
<input type="radio" name="food" id="veg"></td></tr>
<tr>
<td><label for="restro">Selec Restaurant:</label></td>
<td><select>
<option value="opt1">Select Your Restaurants</option>
<option value="opt2">La Figa</option>
<option value="opt3">Benihana</option>
<option value="opt4">Gallipoli</option>
<option value="opt5">Kings Road
SteakHouse</option></select></td></tr>
<tr><td><label for="drinks">Drinks:</label></td><td>
<select>
<option value="opt6">Select Your Drink</option>
<option value="opt7">Caffelatte</option>
<option value="opt8">Cappuccino</option>
</select></td></tr>
<tr><td><label for="soups">Soups:</label></td>
ANKIT SINGH
97
ANKIT SINGH
98
Output
Is used to represent the result of a calculation.
ANKIT SINGH
99
For is used to the relationship between input fields useds and the result
generated for the calculation.
Form the name of one or more forms to which the output tag belongs.
Name a name for the output tag.
<form oninput="x.value=parseInt(a.value)+parseInt(b.value)">
<input type="number" id="a" value="50">
+<input type="number" id="b" value="50">
=<output name="x" for="a b"></output>
</form>
Button
Is used to create a button input type submit.
Type is used to accept the value such as button submit and reset
<html>
<head>
<style>
#button{margin-left:50px;}
...</style>
</head>
<body>
...</tr>
<tr><td>
ANKIT SINGH
100
<button id="button
type="submit"><p>Submit</p></button></td><td><button
type="reset"><p>Reset</p></button></td></tr>
</body>
</html>
ANKIT SINGH
101
A web page is displayed in a browser a user can access information not only
about the current page but also additional details such as information about
window and screen the pages the user has visited in the past or the version the
browser begin used to view the document.
Window
Document
Navigator
Screen
History
Location
Browser object represent the browser environment and provide properties and
methods for its access and manipulation.
ANKIT SINGH
102
ANKIT SINGH
103
A new window displaying the hotel booking form click the hotel image:
Function open_win()
{
ANKIT SINGH
104
Windows.open
(hotelBooking.html,height=100 ,width=200)
}
ANKIT SINGH
105
</SCRIPT>
</head>
<BODY onload="clockTime()">
<DIV ID="displayTime"></DIV>
</BODY>
</html>
ANKIT SINGH
106
Write()
Writeln()
getElementsByName()
getElementsByTagName()
getElenmentsById()
ANKIT SINGH
107
write()
the document.write() method enables users to write text on a web page.
Document.write(Hello);
<html>
<head>
<style>
Body
{
Background-color:#DAA520;
}
</style>
</head>
<body>
<SCRIPT type="text/javascript">
{
var name=prompt("please enter your
name","");
document.write("<p>");
document.write("<i>");
document.write("<b>");
document.write("Welcome "+name);
document.write("</p>");
document.write("</i>");
document.write("</b>");
}
ANKIT SINGH
108
</SCRIPT>
</body>
</html>
Writeln
The writeln() method also writes text on a web page. The only difference is that
the writeln() method appends a new line character at the end of the text.
<html>
<body>
<PRE>
<SCRIPT type="text/javascript">
document.writeln("Hi !");
document.writeln("Welcome to our site!");
document.write("Have a ");
document.write("great day");
</SCRIPT>
</PRE>
</body>
</html>
ANKIT SINGH
109
getElementsByName
the webpage should be specified by a unique name. however multiple element
can also share the same name in a web page the
document.getElementsByName() method
document.getElementsByName(name_of_the_element);
<html>
<SCRIPT type=text/javascript>
function count()
{
var x=document.getElementsByName(link);
alert (x.length + Hyperlinks);
}
</SCRIPT>
<body>
<A name=link href= >Link 1</A><br>
<A name=link href= >Link 2</A><br>
<A name=link href= >Link 3</A><br>
<input type=button value=Count onclick=Count()/>
</body>
</html>
getElementsByTagName
A user can customize the background color of all text boxes on a web page a
drop down list is used to choose the background color. If the user selects the
green color from a drop down list the background color of all the text boxes in
the document changes to green.
document.getElementsByTagName(tag_name);
var x=document.getElementsByTagName(a);
ANKIT SINGH
110
alert(x.length + Hyperlinks);
getElementsById
HTML element used on a web page has an optional attribute ID which uniquely
identifies the element the document.getElementById() method
document.getElementById(id_of_the_element);
<html>
<SCRITP type=text/javascript>
function replacetext()
{
document.getElementById(para1).innerHTML=changes the content
by using the inner HTML property of getElementById() method;
}</SCRIPT>
<body>
<p ID=para1>A simple paragraph</p>
<input type=button value=change text onclick=replacetext()/>
</body>
</html>
Handling Events
ANKIT SINGH
111
ANKIT SINGH
112
ANKIT SINGH
113
ANKIT SINGH
114
<html>
<head>
<title>registration details</title>
<style>
h1,h3{
color:black;
font-size:40px;
text-align:center;
}
table{
margin-left:550px;
border:2px solid white;
background-color:gray;
}
td{
padding:10px;
border:2px solid white;}
#button{
margin-left:670px;}
ANKIT SINGH
115
</style>
<SCRIPT>
function show()
{
var fname=document.getElementById
("textbox1").value;
var lname=document.getElementById
("textbox2").value;
var age=document.getElementById
("age").value;
var address=document.getElementById
("address").value;
var gender=document.getElementById
("gender").value;
confirm("you have entered:"+ "\n name:"+fname + "" +lname+"\n
age:"+ age+"\n address:"+address+"\n gender: "+ gender + "\n\n do
you want to confirm dese details?");
}
function changecolor(val)
{
if ((val.value=="")||(val.value==null))
{
val.style.background="pink";
}
else
{
val.style.background="yellow";
}
ANKIT SINGH
116
}
</SCRIPT>
</head>
<body>
<h1>user registrartion details<hr/></h1>
<h3>plz fill the following details and get registered!!</h3><br/><br/>
<table>
<tr>
<td> first name:</td>
<td> <input type="text" name="name1" id="textbox1"
onblur="changecolor(this)"/> </td>
</tr><tr>
<td>last name:</td>
<td> <input type="text" name="name2" id="textbox2"
onblur="changecolor(this)"/> </td>
</tr><tr>
<td>age:</td>
<td> <input type="text" name="age_box" id="age"
onblur="changecolor(this)"/> </td>
</tr><tr>
<td>address:</td><td> <textarea rows="5" name="address_box"
id="address" onblur="changecolor(this)"/></textarea> </td>
</tr><tr>
<td>gender:</td><td> <select name="gender" id="gender"> <option
value="male">male</option> <option
value="female">female</option> </td>
</tr><tr>
</tr></table>
<br/><input id="button" type="button" value="register me"
onclick="show();"/>
ANKIT SINGH
117
</body>
</html>
ANKIT SINGH
118
Event Listeners
You can handle user actions or event handlers. To handle each and vary user
action or event a listener is notified.
addEventListener()
addEventListener(type,listener[,useCapture]);
ANKIT SINGH
119
120
</html>
ANKIT SINGH
121
<html>
<body>
<SCRIPT type="text/javascript">
document.write(navigator.appName);
document.write(navigator.appVersion);
</SCRIPT>
</body>
</html>
ANKIT SINGH
122
<html>
<body>
<SCRIPT type="text/javascript">
document.write("Height: "+screen.availHeight);
document.write("Width: "+screen.availWidth);
</SCRIPT>
ANKIT SINGH
123
</body>
</html>
<html>
<head>
<SCRIPT type="text/javascript">
function show()
{
alert(history.length);
}
</SCRIPT>
</head>
<body>
<input type="button" value="Show History" onclick="scho()"/>
</body>
</html>
ANKIT SINGH
124
protocol: the protocol such ad HTTP and FTP is used transmit data over
the internet
search: the search string which is any portion of the URL. Followed by a
question mark such as http://www.silvertech.com/careers.html/search?
Programmer.
ANKIT SINGH
125
<form>
<input type=button value=visitus
OnClick=location.href=http://www.xyz.com >
</form>
Form
Button
Checkbox
Text
Textarea
Radio
Select
Form
A form accepts user inputs. When a web page containing multiple forms is
viewed in a browser
ANKIT SINGH
126
reset() reset all the fields of the given form syntax is used for the reset()
method form1.reset()
Onreset: Occurs a user opts for resetting the fields of the form by clicking
the reset button or hyperlink
Button
The button object refers to the HTML button. It allows you to perform several
tasks based on user action.
Checkbox
The checkbox object refers to the HTML check box.
click()
focus()
blur()
document.form1.checkbox1
<html>
<head>
ANKIT SINGH
127
<style>
Body
{
Background-color:pink;
}
</style>
<SCRIPT>
function validate()
{
If(document.f1.check1.checked==false)
{
Alert(please select the check box);
return false
}
else
return turn
}
</SCRIPT>
</head>
<body>
<form name=f1 method=get action=thanks.html
onsubmit=return validate ();>
<input type=checkbox id=check1 />Do you want to accept?
<input type=submit name=submit value=Submit ></input>
<input type=reset name=reset value=Reset></input>
</form>
</body>
</html>
ANKIT SINGH
128
Text
The text object refers to the HTML text box.
onselect: fired when the user selects a part of the text within the text
field. Document.form1.text1
Textarea
The textarea object refers to the HTML textarea the textarea object has similar
method and event attribute
Radio
The radio object refers to an HTML radio button.
Document.form1.radio1
<html>
<head>
<style>
Body
{
Background-color:pink;
}
</style>
<SCRIPT>
function validate()
ANKIT SINGH
129
{
if((document.f1.M.checked==false)&&(document.f1.F.checked==false))
{
alert(please select the gender);
return false
}
else
return true
}
</SCRIPT>
</head>
<body>
<form name=f1 method=get action=thanks.html
onsubmit=return validate();>
Gender:
<input type=radio name=gender id=M/>Male
<input type=radio name=gender id=F/>Female
<input type=submit name=submit value=Submit
align=Center></input>
<input type=reset name=reset value=Reset></input>
</form>
</body>
</html>
Select
The select object refers to the HTML drop down list.
blur()
focus ()
ANKIT SINGH
130
onchange
onfocus
onblur
ANKIT SINGH
131
<option value=2>USA</option>
<option value=3>UKs</option>
</select>
<input type=submit name=submit value=Submit>
<input type=reset name=reset value=Reset>
</form>
</body>
</html>
ANKIT SINGH
132
Graphics
Canvas
Canvas provides an easy and powerful way to create graphic on a web page. A canvas
has on content of its own. A canvas is simply an area on a web page that act as a
container for embedding graphic objects.
ANKIT SINGH
133
A canvas element only create a blank drawing surface however to actually draw graphic
objects on the canvas.
<SCRIPT>
var c=document.getElementById(myCanvas);
var ctx=c.getContext(2d);
</SCRIPT>
rect ()
fillRect ()
strokeRect ()
clearRect ()
rect()
the rect() method is used to create a rectangle on the canvas the default color of the
canvas to draw the outline of the rectangle.
rect(X,Y,width,height);
<html>
<body>
<canvas id="myCanvas" width="300"
height="300" style="border:1px solid black"></canvas>
<SCRIPT>
var c =document.getElementById("myCanvas");
var ctx=c.getContext("2d");
ctx.rect(30,30,120,120);
ctx.stroke();
ANKIT SINGH
134
</SCRIPT>
</body>
</html>
fillRet()
the fillRect () method is used to create a rectangle filled with the specified color. The
default color is black.
fillRect(X,Y,width,height);
<html>
<body>
<canvas id="myCanvas" width="300"
ANKIT SINGH
135
strokeRect()
create a rectangle using by the rect() method you also need to use the stroke() method
to define its outline on the canvas.
strokeRect(X,Y,width,height);
<html>
<body>
<canvas id="myCanvas" width="300" height="300" style="border:1px solid
black"></canvas>
<SCRIPT>
var c =document.getElementById("myCanvas");
var ctx=c.getContext("2d");
ctx.strokeRect(30,30,120,120);
</SCRIPT>
</body>
</html>
ANKIT SINGH
136
clearRect()
the clearRect() method is used to clear a portion of the rectangle it clears the
specified pixels within the given rectangle.
clearRect(X,Y,width,height);
<html>
<body>
<canvas id="myCanvas" width="300" height="300" style="border:1px solid
black"></canvas>
<SCRIPT>
var c =document.getElementById("myCanvas");
var ctx=c.getContext("2d");
ctx.fillRect(30,30,120,120);
ctx.clearRect(50,50,40,40);
</SCRIPT>
</body>
</html>
ANKIT SINGH
137
fillStyle
strikeStyle
shadowcolor
fillStyle
the fillStyle property is used to define a color that will be used to fill any closed shape
drawn on the canvas.
fillStyle=color;
<html>
<body>
<canvas id="myCanvas" width="300" height="300" style="border:1px solid
black"></canvas>
<SCRIPT>
var c =document.getElementById("myCanvas");
var ctx=c.getContext("2d");
ctx.fillStyle="red";
ctx.fillRect(30,30,120,120);
ANKIT SINGH
138
</SCRIPT>
</body>
</html>
strokeStyle
the strokeStyle property is used to set the outline color of a shape drawn on the canvas
strokeStyle=color;
<html>
<body>
<canvas id="myCanvas" width="300" height="300" style="border:1px solid
black"></canvas>
<SCRIPT>
var c =document.getElementById("myCanvas");
var ctx=c.getContext("2d");
ctx.strokeStyle="blue";
ctx.strokeRect(30,30,120,120);
</SCRIPT>
</body>
</html>
ANKIT SINGH
139
shadowColor
you have drawn a shape on the canvas you may want to make it more it more stylish by
creating a shadow on it to graphic object on the canvas
shadowColor=color;
<html>
<body>
<canvas id="myCanvas" width="400" height="300" style="border:1px solid
black"></canvas>
<SCRIPT>
var c =document.getElementById("myCanvas");
var ctx=c.getContext("2d");
ctx.shadowBlur=40;
ctx.fillStyle="pink";
ctx.shadowColor="black";
ctx.fillRect(30,30,120,120);
ctx.shadowColor="blue";
ctx.fillRect(170,30,120,120);
</SCRIPT>
</body>
ANKIT SINGH
140
</html>
addColorStop()
createLinearGradient()
createRadialGradient()
createPattern()
addColorStop()
to create gradients you need to first specify the colors and their position in a gradient
object.
addColorStop(position,color);
position specifies a value between 0.0 to 1.0 to represent the position from
where to start and end the gradient color.
color the color that needs to be applied on the respective position.
createLinearGradient()
the createLinearGradient() method is used to return a gradient object that represent a
linear gradient for painting the color along a line
createLinearGradient(X0,Y0,X1,Y1);
ANKIT SINGH
141
X0
Y0
X1
Y1
<html>
<body>
<canvas id="myCanvas" width="300" height="300" style="border:1px solid
black"></canvas>
<SCRIPT>
var c =document.getElementById("myCanvas");
var ctx=c.getContext("2d");
var grad=ctx.createLinearGradient(0,0,170,0);
grad.addColorStop(0,"blue");
grad.addColorStop("0.5","yellow");
grad.addColorStop(1,"red");
ctx.fillStyle=grad;
ctx.fillRect(20,20,180,180);
</SCRIPT>
</body>
</html>
ANKIT SINGH
142
createRadialGradient()
the createRadialGradient() method is used to return a gradient object that represents a
radial or a circular gradient to be applied on a graphic object.
createRadialGradient(X0,Y0,R0,X1,Y1,R1);
X0
Y0
R0
X1
Y1
R1
<html>
<body>
<canvas id="myCanvas" width="300" height="300" style="border:1px solid
black"></canvas>
<SCRIPT>
var c =document.getElementById("myCanvas");
var ctx=c.getContext("2d");
var grad=ctx.createRadialGradient(75,50,5,90,60,100);
grad.addColorStop(0,"blue");
grad.addColorStop("0.5","yellow");
grad.addColorStop(1,"red");
ctx.fillStyle=grad;
ctx.fillRect(20,20,180,180);
</SCRIPT>
</body>
</html>
ANKIT SINGH
143
createPattern()
is used to create a pattern by displaying an image on a canvas in the specified direction
createPattern(img,repeat|repeat-x|repeart-y|norepeat);
<html>
<body>
<img src="a.jpg" id="pattern">
<button onclick="draw('repeat')">Repeat</button>
<canvas id="myCanvas" width="300" height="300" style="border:1px solid
#d3d3d3;">does not</canvas>
<SCRIPT>
function draw(direction)
{
var c =document.getElementById("myCanvas");
var ctx=c.getContext("2d");
ANKIT SINGH
144
var img=document.getElementById("pattern");
var pat=ctx.createPattern(img,direction);
ctx.rect(0,0,300,300);
ctx.fillStyle=pat;
ctx.fill();
}
</SCRIPT>
</body>
</html>
ANKIT SINGH
145
ANKIT SINGH
146
<html>
<body>
<canvas id="myCanvas" width="300" height="300" style="border:1px solid
#d3d3d3;">does not</canvas>
<SCRIPT>
var c =document.getElementById("myCanvas");
var ctx=c.getContext("2d");
ctx.beginPath();
ctx.moveTo(40,40);
ctx.lineTo(240,40);
ctx.stroke();
</SCRIPT>
</body>
</html>
ANKIT SINGH
147
<html>
<body>
<canvas id="myCanvas" width="300" height="300" style="border:1px solid
#d3d3d3;">does not</canvas>
<SCRIPT>
var c =document.getElementById("myCanvas");
var ctx=c.getContext("2d");
ctx.beginPath();
ctx.arc(80,90,50,0,Math.PI*2,false);
ctx.closePath();
ctx.fillStyle="yellow";
ctx.fill();
</SCRIPT>
</body>
</html>
ANKIT SINGH
148
cp1x
cp1y
cp2x
cp2y
x the
y the
the x-coordinate of
the y-coordinate of
the x-coordinate of
the y-coordinate of
x-coordinate of the
y-coordinate of the
<html>
<body>
<canvas id="myCanvas" width="300" height="300" style="border:1px solid
#d3d3d3;">does not</canvas>
<SCRIPT>
var c =document.getElementById("myCanvas");
var ctx=c.getContext("2d");
ctx.beginPath();
ctx.moveTo(200,20);
ANKIT SINGH
149
ctx.bezierCurveTo(80,20,80,100,150,100);
ctx.stroke();
</SCRIPT>
</body>
</html>
fillText()
the fillText() method is used to draw a text filled with solid color on a canvas.
fillText(text,x,y,width);
ANKIT SINGH
150
<html>
<body>
<canvas id="myCanvas" width="300" height="300" style="border:1px solid
#d3d3d3;">does not</canvas>
<SCRIPT>
var c =document.getElementById("myCanvas");
var ctx=c.getContext("2d");
ctx.font="15px Georgia";
ctx.fillText("Fill Text",10,60,120);
ctx.font="15x Verdana";
var gradient=ctx.createLinearGradient(0,0,170,0);
gradient.addColorStop("0","magenta");
gradient.addColorStop("0.5","blue");
gradient.addColorStop("1","red");
ctx.fillStyle=gradient;
ctx.fillText("Fill Text with Gradient",10,90,120);
</SCRIPT>
</body>
</html>
ANKIT SINGH
151
strokeText()
the strokeText() method is used to draw a text at the specified position on the canvas by
using the current font style and color.
strokeText(text,x,y,width);
<html>
<body>
<canvas id="myCanvas" width="300" height="300" style="border:1px solid
#d3d3d3;">does not</canvas>
<SCRIPT>
var c =document.getElementById("myCanvas");
var ctx=c.getContext("2d");
ctx.font="15px Georgia";
ctx.strokeText("Fill Text",10,60,120);
ctx.font="15x Verdana";
var gradient=ctx.createLinearGradient(0,0,170,0);
gradient.addColorStop("0","magenta");
gradient.addColorStop("0.5","blue");
ANKIT SINGH
152
gradient.addColorStop("1","red");
ctx.strokeStyle=gradient;
ctx.strokeText("Fill Text with Gradient",10,90,120);
</SCRIPT>
</body>
</html>
ANKIT SINGH
153
<html>
<body onload=setImage()>
<canvas id="myCanvas" width="300" height="300" style="border:1px solid
#d3d3d3;">does not</canvas>
<SCRIPT>
function setImage()
{
var c =document.getElementById("myCanvas");
var ctx=c.getContext("2d");
var img=new Image();
img.src="a.jpg"
img.onload=function()
{
ctx.drawImage(img,10,10,150,150);
}
}
</SCRIPT>
</body>
</html>
ANKIT SINGH
154
translate()
scale()
rotate()
translate
the translate () method is used to reset the origin of the canvas to the specified position.
translate(x,y);
var c=document.getElementById(myCanvas);
var ctx=c.getContext(2d);
ctx.fillStyle=red;
ctx.fillRect(10,10,100,100);
<html>
<body >
<canvas id="myCanvas" width="300" height="300" style="border:1px solid
#d3d3d3;">does not</canvas>
<SCRIPT>
ANKIT SINGH
155
var c =document.getElementById("myCanvas");
var ctx=c.getContext("2d");
ctx.fillStyle="red";
ctx.fillRect(10,10,100,100);
ctx.translate(50,25);
ctx.fillStyle="blue";
ctx.fillRect(10,10,100,100);
</SCRIPT>
</body>
</html>
Scale
The scale () method is used to increase or decrease the units in the canvas grid.
scale(scalewidth,scaleheight);
scalewidth the width (in percentage) a graphic object should be scaled to.
scaleheight the length(in percentage) a graphic object should be scale to.
<html>
ANKIT SINGH
156
<body >
<canvas id="myCanvas" width="300" height="300" style="border:1px solid
#d3d3d3;">does not</canvas>
<SCRIPT>
var c =document.getElementById("myCanvas");
var ctx=c.getContext("2d");
ctx.fillStyle="red";
ctx.fillRect(10,10,100,100);
ctx.translate(50,25);
ctx.scale(2,2);
ctx.fillStyle="blue";
ctx.fillRect(10,10,100,100);
</SCRIPT>
</body>
</html>
Rotate
ANKIT SINGH
157
The rotate() method is used to rotate the graphic object to a degree in the clockwise
direction
rotate(angle);
<html>
<body >
<canvas id="myCanvas" width="300" height="300" style="border:1px solid
#d3d3d3;">does not</canvas>
<SCRIPT>
var c =document.getElementById("myCanvas");
var ctx=c.getContext("2d");
ctx.fillStyle="red";
ctx.fillRect(10,10,100,100);
ctx.rotate(25);
ctx.fillStyle="blue";
ctx.fillRect(40,40,100,100);
</SCRIPT>
</body>
</html>
ANKIT SINGH
158
<html>
<head>
</head>
<BODY>
<CANVAS Id="canvas" width="400"
height="300" style="border:2px solid black">
</CANVAS>
<SCRIPT type="text/javascript">
var canvas;
var ctx;
var x = 390;
var y = 290;
var dx = 2;
var dy = 2;
var WIDTH = 400;
var HEIGHT = 300;
function circle() {
ctx.beginPath();
ctx.fillStyle="red";
ctx.arc(x,y,10,0,Math.PI*2,true);
ctx.fill();
ctx.closePath();
ANKIT SINGH
159
}
function clear() {
ctx.clearRect(0, 0, WIDTH, HEIGHT);
}
function init() {
canvas = document.getElementById
("canvas");
ctx = canvas.getContext("2d");
return setInterval(draw, 10);
}
function draw() {
clear();
circle();
if (x> WIDTH || x< 12)
dx = -dx;
if (y> HEIGHT || y< 12)
dy = -dy;
x += dx;
y += dy;
}
init();
</SCRIPT>
</BODY>
</html>
ANKIT SINGH
160
Project time
<!DOCTYPE html>
<html>
<body>
<canvas id="canvas" width="400" height="400">
</canvas>
<script>
var canvas = document.getElementById("canvas");
var ctx = canvas.getContext("2d");
var radius = canvas.height / 2;
ctx.translate(radius, radius);
radius = radius * 0.90
ANKIT SINGH
161
setInterval(drawClock, 1000);
function drawClock() {
drawFace(ctx, radius);
drawNumbers(ctx, radius);
drawTime(ctx, radius);
}
ANKIT SINGH
162
var num;
ctx.font = radius*0.15 + "px arial";
ctx.textBaseline="middle";
ctx.textAlign="center";
for(num = 1; num < 13; num++){
ang = num * Math.PI / 6;
ctx.rotate(ang);
ctx.translate(0, -radius*0.85);
ctx.rotate(-ang);
ctx.fillText(num.toString(), 0, 0);
ctx.rotate(ang);
ctx.translate(0, radius*0.85);
ctx.rotate(-ang);
}
}
ANKIT SINGH
163
ANKIT SINGH
164
ANKIT SINGH
165
Geolocation
Implementing Geolocation
The store offers clothes accessories and footwear in addition it sells the home furnishing
goods and electronic items such as refrigerator air conditioner laptops and mobile
devices.
Using the Geolocation API the Geolocation API-enabled website can locate users current
geographical location display points of interest around that location or guide the users
from their current location to a target destination.
getCurrentPosition()
watchPosition()
getCurrentPosition()
the getCurrentPosition() method is used to retrieve the current geographical location of a
user the location is retrieved as a set of coordinate
getCurrentPosition(callbackFunction,ErrorHandler,Options);
ANKIT SINGH
166
<!DOCTYPE html>
<html>
<body>
<p>Click the button to get your coordinates.</p>
<button onclick="getLocation()">Try It</button>
<p id="demo"></p>
<script>
var x = document.getElementById("demo");
function getLocation() {
if (navigator.geolocation) {
navigator.geolocation.getCurrentPosition(showPosition);
} else {
x.innerHTML = "Geolocation is not supported by this browser.";
}
}
ANKIT SINGH
167
function showPosition(position) {
x.innerHTML = "Latitude: " + position.coords.latitude +
"<br>Longitude: " + position.coords.longitude;
}
</script>
</body>
</html>
watchPosition()
the watchPosition() method return the current location of a user and continuously update
the location while user is moving. The watchPosition ()
method takes the same parameter as the getCurrentPosition() method and returns
the same object.
<!DOCTYPE HTML>
<head>
<html>
<script type="text/javascript">
var watchID;
var geoLoc;
function showLocation(position)
{
var latitude = position.coords.latitude;
var longitude = position.coords.longitude;
alert("Latitude : " + latitude + " Longitude: " + longitude);
}
function errorHandler(err) {
if(err.code == 1) {
alert("Error: Access is denied!");
ANKIT SINGH
168
function getLocationUpdate(){
if(navigator.geolocation){
// timeout at 60000 milliseconds (60 seconds)
var options = {timeout:60000};
geoLoc = navigator.geolocation;
watchID = geoLoc.watchPosition(showLocation, errorHandler,
options);
}
else{
alert("Sorry, browser does not support geolocation!");
}
}
</script>
</head>
<body>
<form>
<input type="button" onclick="getLocationUpdate();" value="Watch
Update"/>
</form>
</body>
</html>
ANKIT SINGH
169
Handling Errors
User may not provide the permission to access his location. This may raise an error in
your website. The error may also occur when a user checks the current location on a
mobile device and the device goes out of coverage area or the network connection is
time out error.
Permission_denied that the user has declined the request to share the location
Position_unavailable that the users current location cannot be retrieved.
Timeout that the time given to retrieve the users location exceeded the
maximum limit.
Unknoen_error that an unknown or undefined error has occurred.
<!DOCTYPE html>
<html>
<body>
<p>Click the button to get your coordinates.</p>
<button onclick="getLocation()">Try It</button>
<p id="demo"></p>
<script>
var x = document.getElementById("demo");
function getLocation() {
if (navigator.geolocation) {
navigator.geolocation.getCurrentPosition(showPosition, showError);
} else {
x.innerHTML = "Geolocation is not supported by this browser.";
}
}
function showPosition(position) {
x.innerHTML = "Latitude: " + position.coords.latitude +
"<br>Longitude: " + position.coords.longitude;
}
function showError(error) {
ANKIT SINGH
170
switch(error.code) {
case error.PERMISSION_DENIED:
x.innerHTML = "User denied the request for Geolocation."
break;
case error.POSITION_UNAVAILABLE:
x.innerHTML = "Location information is unavailable."
break;
case error.TIMEOUT:
x.innerHTML = "The request to get user location timed out."
break;
case error.UNKNOWN_ERROR:
x.innerHTML = "An unknown error occurred."
break;
}
}
</script>
</body>
</html>
Offline Support
Ensures that the website is available even when the user is not connected to the
network.
Reduces network load on the server. You can make your website work offline by
using the
Implement client-side storage
Implement application cache
Client-side storage
The client-side storage refers to the process of storing data locally within the users
browser the date stored by using client-side storage is retrieved only when it is
requested the date stored in the key value pairs.
ANKIT SINGH
171
localStorage
sessionStorage
localStorage
the localStorage object allow you to store data without any expiration date. The implies
that the date stored by using the localStorage .
<!DOCTYPE html>
<html>
<body>
<div id="result"></div>
<script>
// Check browser support
if (typeof(Storage) !== "undefined") {
// Store
localStorage.setItem("lastname", "Smith");
// Retrieve
document.getElementById("result").innerHTML =
localStorage.getItem("lastname");
} else {
document.getElementById("result").innerHTML = "Sorry, your browser does
not support Web Storage...";
}
</script>
</body>
</html>
sessionStorage
the sessionStorage object is used to store the data for only one session.
<!DOCTYPE html>
<html>
<head>
ANKIT SINGH
172
<script>
function clickCounter() {
if(typeof(Storage) !== "undefined") {
if (sessionStorage.clickcount) {
sessionStorage.clickcount = Number(sessionStorage.clickcount)+1;
} else {
sessionStorage.clickcount = 1;
}
document.getElementById("result").innerHTML = "You have clicked the
button " + sessionStorage.clickcount + " time(s) in this session.";
} else {
document.getElementById("result").innerHTML = "Sorry, your browser
does not support web storage...";
}
}
</script>
</head>
<body>
<p><button onclick="clickCounter()" type="button">Click me!
</button></p>
<div id="result"></div>
<p>Click the button to see the counter increase.</p>
<p>Close the browser tab (or window), and try again, and the counter is
reset.</p>
</body>
</html>
Offline browsing that a website can be viewed even if the user is not connected
to the internet.
ANKIT SINGH
173
Speed that if the user request the web page which is already there in the cache
it is retrieved from the cache and not from the server.
Reduced server load that the web page if cached will always be made available
from the cache unless the browser detects that the cache manifest has been
updated on the server or user has cleared the browser cache.
Cache the files that need to be cached after they are downloaded for the first
time.
Network the files that should never be cached.
Fallback the task to be performed a user tries to fetch the uncached files.
<html manifest=HotelFacilities.appcache>
ANKIT SINGH
174
jQuery
The website should be designed in such a way that it displays the product categories
and items in the sliding and collapsible menu and submenu format the web designer has
been asked to complete the task quickly and keep the code simple for this situation the
designer can use the prewritten JavaScript library known as jQuery.
Manipulating HTML Element by Using jQuery
You can make use of jQuery in a web page to manipulate HTML element by using jQuery.
The using jquery before you need to download jquery-1.8.3.js file. It can be referred
to the web page by using the <SCRIPT>tag in the head section.
<SCRIPT type=text/javascript src=path/jquery-1.8.3.js>
</SCRIPT>
The SCRIPT tag instructs the browser that the HTML document uses a script.
The type attribute specifies the type of scripting used.
The src is used to path of jquery file store in your hard drive.
document.ready()
this function contains the jquery code to be executed on HTML element after the web
page has been fully loaded in the browser.
<SCRIPT type="text/javascript"
src="F:\HTML\class\jQueryS\jquery.1.8.3.js">
$(document).ready(function(){//jQuery code})
</SCRIPT>
The dollar sing ($) represent start of the jQuery code block and jQuery code is the code
to be implemented for the document.ready() function
$ (selector).action();
The selector is the element to be manipulated and action represents action to be taken
on the selector element.
<html>
<head>
ANKIT SINGH
175
<SCRIPT type="text/javascript"
src="F:\HTML\class\jQueryS\jquery.1.8.3.js">
</SCRIPT><SCRIPT>
$(document).ready(function(){//jQuery code})
</SCRIPT>
</head>
<body>
...
</body>
jQuery HTML
the JQuery provides predefined functions to perform modifications on the content of
HTML elements.
ANKIT SINGH
176
ANKIT SINGH
177
<html>
<head>
<SCRIPT type="text/javascript"
src="F:\HTML\class\jQueryS\jquery.1.8.3.js">
</SCRIPT><SCRIPT>
$(document).ready(function(){$("button").click (function() { $
("#para").prepend("<b>jQuery<b>"); $("#para").append('<h3> This is the
newly inserted heading.</h3>');
$("#newhead").remove();});});
</SCRIPT>
</head>
<body>
<div align="center"></div>
<h3>Complete the sentence:</h3>
ANKIT SINGH
178
ANKIT SINGH
179
ANKIT SINGH
180
ANKIT SINGH
181
ANKIT SINGH
182
Visual Effects
Hide
Show
Toggle
Slide
Fade
Animate
Hide Effect
The hide() function is used to make an element disappear when an event such as click or
double-click occurs.
$(selector).hide(speed)
<!DOCTYPE html>
<html>
<head>
<script
src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></
script>
<script>
$(document).ready(function(){
$("button").click(function(){
$("p").hide(1000);
});
});
</script>
</head>
<body>
<button>Hide</button>
<p>This is a paragraph with little content.</p>
<p>This is another small paragraph.</p>
</body>
</html>
ANKIT SINGH
183
Show Effect
The show() function is used to make a hidden element visible when an event occurs.
$(selector).show(speed)
<!DOCTYPE html>
<html>
<head>
<script src="F:\HTML\class\jQueryS
\jquery.1.8.3.js"></script>
<script>
$(document).ready(function(){
$("#hide").click(function(){
$("p").hide();
});
$("#show").click(function(){
$("p").show();
});
ANKIT SINGH
184
});
</script>
</head>
<body>
Toggle Effect
The toggle () function is used to switch between the show and hide effects of an
element.
$(selector).toggle(speed)
<!DOCTYPE html>
<html>
<head>
<script src="F:\HTML\class\jQueryS\jquery.1.8.3.js"></script>
<script>
$(document).ready(function(){
$("button").click(function(){
$("p").toggle();
});
});
</script>
</head>
<body>
ANKIT SINGH
185
</body>
</html>
Slide Effect
The slide effect used to produce a sliding effect on the selected element. The slide
functions slideDown() slideUp() and slideToggle()
slideDown()
$(selector).slideDown(speed)
slideUp()
$(selector).slideUp(speed)
slideToggle()
$(selector).slideToggle(speed)
<!DOCTYPE html>
<html>
<head>
<script src="F:\HTML\class\jQueryS\jquery.1.8.3.js"></script>
<script>
$(document).ready(function(){
$("#flip").mouseenter(function(){
$("#panel").slideToggle("slow");
});
});
</script>
ANKIT SINGH
186
<style>
#panel, #flip {
padding: 5px;
text-align: center;
background-color: #e5eecc;
border: solid 1px #c3c3c3;
}
#panel {
padding: 50px;
display: none;
}
</style>
</head>
<body>
</body>
</html>
Fade Effect
Fade effect is used to gradually reduce the opacity of the selected elements.
ANKIT SINGH
187
<!DOCTYPE html>
<html>
<head>
<script
src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></
script>
<script>
$(document).ready(function(){
$("button").click(function(){
$("#div1").fadeOut();
$("#div2").fadeOut("slow");
$("#div3").fadeOut(3000);
});
});
</script>
</head>
ANKIT SINGH
188
<body>
<p>Demonstrate fadeOut() with different parameters.</p>
<button>Click to fade out boxes</button><br><br>
<div id="div1" style="width:80px;height:80px;background-color:red;">
</div><br>
<div id="div2" style="width:80px;height:80px;background-color:green;">
</div><br>
<div id="div3" style="width:80px;height:80px;background-color:blue;">
</div>
</body>
</html>
Animate Effect
The animate effect is used to create custom animation.
Animate({params},speed,callback);
ANKIT SINGH
189
height: '150px',
width: '150px'
});
});
});
</script>
</head>
<body>
<div
style="background:#98bf21;height:100px;width:100px;position:absolute;">
</div>
</body>
</html>
Image Rollover
The images can be replaced by other images at runtime by creating the image rollover
effect.
<!DOCTYPE html>
<html>
<body>
<p>The function bigImg() is triggered when the user moves the mouse pointer
over the image.</p>
<p>The function normalImg() is triggered when the mouse pointer is moved
out of the image.</p>
<script>
function bigImg(x) {
x.style.height = "64px";
x.style.width = "64px";
ANKIT SINGH
190
}
function normalImg(x) {
x.style.height = "32px";
x.style.width = "32px";
}
</script>
</body>
</html>
Image Gallery
An image gallery is a collection of thumbnail pictures or image links. All of these can be
clicked individually to provide a large view of the corresponding product on another web
page.
Colorbox plugin enables displaying a collection of images one by one by using the
previous and next button and variety of transition effects.
If you want to use this effect than you need to download a colorbox.zip file.
Colorbox this folder comprises the jquery.colorbox.js file. Is used to implement the
lightbox slideshow and the transition effects.
Colorbox.css style sheet contains the formatting instructions to stylize position and
decorate the image gallery.
<html>
<head>
<link media="screen" rel="stylesheet"
href="F:\HTML\class\demo\colorbox.css"/>
<script src="F:\HTML\class\jQueryS\jquery.1.8.3.js"></script>
<script src="F:\HTML\class\jQueryS\jquery.colorbox.js"></script>
ANKIT SINGH
191
<script type="text/javascript">
$(document).ready(function(){
$("a").colorbox({transition:"fade",height:"250",width:"220"});
});
</script>
</head>
<body>
<h1 product demonstration</h1>
<a href="a.jpg">shanu</a>
</body>
</html>
Galleria plugin
This plugin is used to display image gallery and create thumbnails of the images to be
displayed in the gallery automatically. When the mouse pointer is moved on a thumbnail
image is large version of image.
If you want to used galleria plugin you need to download the galleria.zip file
ANKIT SINGH
192