Web Tech File Code Only
Web Tech File Code Only
Web Tech File Code Only
h1-h6,paragraph,comments,title etc)
CODE
<!doctype html>
<html>
<head>
<title>SAHIL PATHAK</title>
</head>
<body>
<h1 align="center">SAHIL</h1>
</body>
</html>
1
OUTPUT
PROGRAM-2
Prints an hl level heading followed by a horizontal line whose width is 100%. Below the
horizontal line print a paragraph relating to the text in the heading.
CODE
<!doctype html>
<html>
<head>
<title>SAHIL PATHAK</title>
</head>
<body>
<h1 align="center">SAHIL</h1><hr>
2
</body>
</html>
OUTPUT
PROGRAM-3
i. Print a paragraph that is a description of a book, include the title of the book as well as its
author. Names and titles should be underlined. Use italics and bold and other text formatting tags
wherever necessary.
CODE
<!doctype html>
<html>
<head>
<title>SAHIL PATHAK</title>
</head>
<body>
upon Thames to Oxford and back to Kingston. <strike>The book was initially
intended to be a serious travel guide, with accounts of local history along the
route, but the humorous elements took over to the point where the serious and somewhat
3
sentimental passages seem a distraction to the comic novel. <strong>One of the most</strong>
praised things about <em>Three Men in a Boat</em> is how undated it appears to modern readers
</body>
</html>
OUTPUT
ii. Print your name to the screen with every letter being a different heading size.
CODE
4
<!doctype html>
<html>
<head>
<title>SAHIL PATHAK</title>
</head>
<body>
<h1>s</h1><h2>a</h2><h3>h</h3><h4>i</h4><h5>l</h5>
</body>
</html>
OUTPUT
PROGRAM-4
Print the squares of the numbers 1 - 10. Each number should be on a separate line, next to it the
number 2 superscripted, an equal sign and the result. (Example: 12 = 1)
CODE
<!doctype html>
<html>
<head>
<title>SAHIL PATHAK</title>
5
</head>
<body>
1<sup>2</sup>=1<br>
2<sup>2</sup>=4 <br>
3<sup>2</sup>=9 <br>
4<sup>2</sup>=16<br>
5<sup>2</sup>=25<br>
6<sup>2</sup>=36<br>
7<sup>2</sup>=49<br>
8<sup>2</sup>=64<br>
9<sup>2</sup>=81<br>
10<sup>2</sup>=100<br>
</body>
</html>
OUTPUT
6
PROGRAM-5
Print two addresses in the same format used on the front of envelopes (sender’s address in top
left corner, receivers address in the center)
CODE
<!doctype html>
<html>
<head>
<title>SAHIL PATHAK</title>
</head>
<body>
<address><pre>sahil pathak
ashok vihar,delhi-110052</pre></address>
pitampura,delhi-110034</pre></address>
</body>
</html>
7
OUTPUT
PROGRAM-6
Create a web page giving the following train details: Train name. Starting place, Destination,
Arrival and Departure time., Fare.
Place a border for the table and use cell padding to present cell data with clarity with colors too.
Align the table in center of the screen. Use a caption saying - Time Table and Fare list".
CODE
<!doctype html>
<html>
<head>
<title>SAHIL PATHAK</title>
</head>
<body>
<th rowspan="2">Place</th>
<th rowspan="2">Destination</th>
<th colspan="2">Time</th>
<th rowspan="2">Fare</th>
</tr>
8
<th >Arrival</th>
<th >Departure</th>
</tr>
<td >Rajdhani</td>
<td >Bombay</td>
<td >Delhi</td>
<td>07:30</td>
<td>09:45</td>
<td >Rs.100</td>
</tr>
<td >Deccan</td>
<td >Madras</td>
<td >Delhi</td>
<td>05:30</td>
<td>02:45</td>
<td >Rs.200</td>
</tr>
<td >Delhi</td>
<td >Bombay</td>
<td>02:30</td>
<td>06:10</td>
<td >Rs.200</td>
9
</tr>
</table>
</body>
</html>
OUTPUT
PROGRAM-7
10
CODE
<!doctype html>
<html>
<head>
<title>SAHIL PATHAK</title>
</head>
<body>
<tr>
</tr>
<tr>
<td align="center">cell 2
<tr>
</tr>
<tr>
</tr>
<tr>
</tr>
11
</table>
</td>
</tr>
</table>
</body>
</html>
OUTPUT
PROGRAM-8
Write an HTML code using list tags to generate the following output:-
Website outline
1.Home page
2.Links page
A. News sites
B .Stock sites
3.Feedback page
Item 1
Item 2
* Contacts
* Html example
Coding
12
It should be done for HTML
Newsgroup
These are created for data sharing.
CODE
<!doctype html>
<html>
<head>
<title>SAHIL PATHAK</title>
</head>
<body>
<ol type="1">
<li>Home Page</li>
<li>Links Page</li>
<ol type="A">
<li>News sites</li>
<li>Stock sites</li>
</ol>
<li>Feedback page</li>
<ul type="disc">
<li>Item 1</li>
<li>Item 2</li>
<ul type="circle">
<li>Contacts</li>
<li>HTML example</li>
</ul>
13
<dl>
<dt>Coding</dt>
<dt>Newsgroup</dt>
</dl>
</ul>
</ol>
</body>
</html>
OUTPUT
14
PROGRAM-9
Write a program in HTML using anchor element to show the following output with
hyperlinks.
Here are my favorite Internet Search Engines
Yahoo: http://www.yahoo.com
Google: http://www.google.com
<!doctype html>
<html>
<head>
<title>SAHIL PATHAK</title>
</head>
<body>
<p align="center"><b>Yahoo:</b><a
href="http:://www.yahoo.com">http:://www.yahoo.com</a></p>
<p align="center"><b>Google:</b><a
href="http:://www.google.com">http:://www.google.com</a></p>
</body>
</html>
15
OUTPUT
PROGRAM-10
<body bgcolor="#87FF14">
<form align="center">
<form method="post"action="/cgi-bin/formmail">
<input type="hidden"name="recipient"value="[email protected]">
16
<h3 align="center" style="color:red" >Personal Details</h3>
<br><br>
<br><br>
<br><br>
<br><br>
<br><br>
<option>B.COM
<option>M.COM
<option>B.A
<option>M.A
<option>B.Sc
</select>
<br><br>
17
<select name="Engineering" >
<option>B.Tech
<option>M.Tech
<option>BCA
<option>MCA
</select>
<br><br>
<br>
<br><br>
<br><br>
</form>
</body>
</html>
OUTPUT
PROGRAM-11
<!doctype html>
<html>
<head>
<title>SAHIL PATHAK</title>
</head>
<body >
<form align="center">
<form method="post"action="/cgi-bin/formmail">
<input type="hidden"name="recipient"value="[email protected]">
<br>
<br><br>
<br><br>
<br><br>
<br><br>
<br><br>
19
<label for="State"align = "left">State</label>
<option>Delhi
<option>Gujarat
<option>Mumbai
<option>Punjab
<option>Bangalore
</select>
<br><br>
<br><br>
<br><br>
<br><br>
<br><br>
<input type="submit">
<input type="reset">
</form>
20
</body>
</html>
OUTPUT
PROGRAM-12
Write an HTML code to demonstrate various types of frames and also use meta tag in it.
<!doctype html>
<html>
<head>
<title>SAHIL PATHAK</title>
</head>
<frameset cols="20,80">
<frame src="flower1.jfif">
<frame src="flower2.jfif">
</frameset>
</html>
OUTPUT
21
CODE
<!doctype html>
<html>
<head>
<title>SAHIL PATHAK</title>
</head>
<frameset rows="20,80">
<frame src="flower1.jfif">
<frame src="flower2.jfif">
<frame src="flower3.jfif">
</frameset>
</frameset>
</html>
OUTPUT
<!doctype html>
<html>
<head>
<title>SAHIL PATHAK</title>
</head>
22
</html>
OUTPUT
<!doctype html>
<html>
<head>
<title>SAHIL PATHAK</title>
</head>
<frameset cols="20,80">
<frame src="prog8for12.4.html"name="f2">
</frameset>
</html>
OUTPUT
23
PROGRAM-13
Write HTML code using image map and its various attributes
CODE
<!doctype html>
<html>
<head>
<title>SAHIL PATHAK</title>
</head>
<body>
<map name="workmap">
</map>
</body>
24
</html>
OUTPUT
PROGRAM-14
Write HTML code to show the use of name attribute for internal linking concept.
CODE
<!doctype html>
<html>
<head>
25
<title>SAHIL PATHAK</title>
</head>
<body>
<h3><a href="#ch1">Chapter1</a><br></h3><br>
<h3><a href="#ch2">Chapter2</a><br></h3><br>
<h3><a href="#ch3">Chapter3</a><br></h3><br>
<h3><a href="#ch4">Chapter4</a><br></h3><br>
<h3><a href="#ch5">Chapter5</a><br></h3><br>
<h3><a href="#ch6">Chapter6</a><br></h3><br><br><br><br><br>
<p>HTML Basics</p><br><br><br><br>
<p>HTML Commands</p><br><br><br><br>
<p>HTML Attributes</p><br><br><br><br>
<p>HTML Tables</p><br><br><br><br>
<p>HTML Frames</p><br><br><br><br>
</body>
</html>
OUTPUT
26
27
AFTER CLICKING ON CHAPTER 3 LINK OUPUT
PROGRAM-15
<!DOCTYPE html>
<html lang="en">
<head>
<title>Document</title>
</head>
<body>
<h4 id="mainIntro">Here we debug everything, from life to lines of code! <br> Hope you enjoy!
</h4>
<p class="para1">
28
</pre>
</p>
</body>
</html>
CSS FILE
*{ /* universal selector */
text-align: center;
h1 { /* element selector */
font-family: Consolas;
color:red;
#mainIntro { /* id selector */
background-color: aquamarine;
.para1 {
background-color:blueviolet;
OUTPUT
29
PROGRAM-16
<!doctype html>
<html>
<head>
</head>
<body>
<h1>This is heading</h1>
<p>This is paragraph</p>
</body>
</html>
CSS FILE
body
background-color:lightblue
h1
color:navy
margin-left:20px
30
OUTPUT
b) Internal Stylesheet
CODE
<!doctype html>
<html>
<head>
<style>
body
31
{
background-color:linen
h1
color:maroon
margin-left:40px
</style>
</head>
<body>
<h1>This is heading</h1>
<p>This is paragraph</p>
</body>
</html>
OUTPUT
32
c) Inline Stylesheet
CODE
<!doctype html>
<html>
<head>
</head>
<body>
</body>
</html>
OUTPUT
33
PROGRAM-17
Write code in HTML to style the shopping list given below using CSS
CODE
<!doctype html>
<html>
<head>
</head>
<body>
<ul>
<li>bread</li>
<ul>
34
<li> whole wheat bread</li>
</ul>
<li>Rice</li>
<li>Potatoes</li>
</ul>
</body>
</html>
CSS File
text-decoration:none
A:hover
text-decoration:underline;color:red;background-color:#CCFFCC
li em
color:green;font-weight:bold
ul
margin-left:2cm
35
ul ul
text-decoration:underline;margin-left:.15cm
OUTPUT
PROGRAM-18
<!doctype html>
<html>
36
<head>
<style>
#sticky
height:150px;
width:150px;
background:yellow;
position:sticky;
top:10px;
left:100px;
#fixed
height:150px;
width:150px;
background:pink;
position:fixed;
top:70px;
left:400px;
#relative
37
{
height:150px;
width:150px;
background:red;
position:relative;
top:150px;
left:200px;
#absolute
height:150px;
width:150px;
background:green;
position:absolute;
top:500 px;
left:100px;
#static
height:150px;
width:150px;
background:orange;
38
border:1px solid #000;
position:static;
body
background-color:linen
h1
color:maroon
margin-left:40px
</style>
</head>
<body>
<h1>This is heading</h1>
<p><pre>different types
of postions in html
Elements are
properties. However,
39
these properties
the position
property is
set first.
differently depending
<div id="relative">relative</div>
<p><pre>different types
of postions in html
Elements are
properties. However,
these properties
the position
property is
differently depending
40
<div id="absolute">absolute</div>
</body>
</html>
OUTPUT
41
PROGRAM-19
<!doctype html>
<html>
<head>
<style>
a:visited
{
color:brown
}
a:hover
{
color:aqua
}
a:link
{
color: darkgreen;
}
a:active
{
color: red;
}
</style>
</head>
<body>
<h1>program to set link properties</h1>
<a href="https://practice.geeksforgeeks.org">geeks for geeks</a><br>
<a href="https://en.wikipedia.org/wiki/.org">wikipedia</a><br>
</body>
</html>
OUTPUT
42
PROGRAM-20
CODE
<!DOCTYPE html>
<html>
<head>
<style>
table
{
43
empty-cells: hide;
border-collapse: collapse;
}
table, td, th
{
border: 4px solid black;
border-spacing: 20px;
}
caption
{
caption-side: bottom;
}
#customers tr:nth-child(even)
{
background-color:yellow;
}
th
{
background-color:green;
color: white;
}
</style>
</head>
<body>
<h2>Setting Table properties:</h2>
<table id="customers">
<tr>
<th>Company</th>
<th>Contact</th>
<th>Country</th>
</tr>
<tr>
<td>Alfreds Futterkiste</td>
<td>Maria Anders</td>
<td>Germany</td>
</tr>
<tr>
<td>Berglunds snabbkp</td>
<td>Christina Berglund</td>
<td>Sweden</td>
</tr>
<tr>
<td>Centro comercial Moctezuma</td>
<td>Francisco Chang</td>
<td>Mexico</td>
44
</tr>
<tr>
<td>Ernst Handel</td>
<td>Roland Mendel</td>
<td>Austria</td>
</tr>
<tr>
<td>Island Trading</td>
<td>Helen Bennett</td>
<td>UK</td>
</tr>
<tr>
<td>Koniglich Essen</td>
<td>Philip Cramer</td>
<td>Germany</td>
</tr>
<tr>
<td>Laughing Bacchus Winecellars</td>
<td>Yoshi Tannamuri</td>
<td>Canada</td>
</tr>
<tr>
<td>Magazzini Alimentari Riuniti</td>
<td>Giovanni Rovelli</td>
<td>Italy</td>
</tr>
<tr>
<td>North/South</td>
<td>Simon Crowther</td>
<td>UK</td>
</tr>
<tr>
<td>Paris spcialits</td>
<td>Marie Bertrand</td>
</tr>
</table>
</body>
OUTPUT
45
PROGRAM-21
Write code in CSS to style Lists using various list style setting properties
CODE
<html>
<head>
<style>
ul.a
{
list-style-position: inside;
list-style-type:circle;
}
ol.b
{
list-style-position: outside;
list-style: upper-roman;
}
ul.c
{
list-style-position:inside;
list-style-image: url("coffee.png");
}
</style>
</head>
<body>
<p>example of unordered list</p>
<ul class ="a">
<li>coffee</li>
<li>tea</li>
<li>coca cola</li>
</ul>
<p>example of ordered list</p>
<ol class ="b">
<li>coffee</li>
<li>tea</li>
<li>coca cola</li>
</ol>
<p>example of unordered list</p>
<ul class ="c">
<li>coffee</li>
<li>tea</li>
<li>coca cola</li>
46
</ul>
</body>
</html>
OUTPUT
47
PROGRAM-22
<html>
<head>
<style>
p.normal
{
font-size: "40px";
font-family:Times New Roman ;
font-weight: normal;
font-style: normal;
}
p.italic
{
font-size: "14px";
font-family:Arial ;
font-weight: bold;
font-style: italic;
font-variant: small-caps;
}
</style>
</head>
<body>
<p class="normal">this is a para in normal</p>
<p class="normal">normal text continued</p>
<p class="italic">this is a para in italic</p>
</body>
</html>
OUTPUT
48
PROGRAM-23
<html>
<head>
<link rel="stylesheet" href="stylebg.css">
<style>
p
{
background-color: burlywood;
}
</style>
</head>
<body>
<p style="background-color:aqua">hello world</p>
<p>hello world</p>
<p>hello world</p>
<p>hello world</p>
</body>
</html>
CSS CODE
p
{
background-color:pink;
}
OUTPUT
49
PROGRAM-24
Write program in javascript to display various data types and their types using typeof
operator
CODE
<!doctype html>
<html>
<head>
<title>data types of js</title>
</head>
<body>
<script>
var x="hello";
var y=24;
var z=34.5;
var a;
var b=null;
var c=["red","yellow","green"];
var d={"name":"sahil","surname":"pathak"};
var f=function()
{
return "hello world";
}
document.writeln(typeof x+"<br>");
document.writeln(typeof y+"<br>");
document.writeln(typeof z+"<br>");
document.writeln(typeof a+"<br>");
document.writeln(typeof b+"<br>");
document.writeln(typeof c+"<br>");
document.writeln(typeof d+"<br>");
document.writeln(typeof f+"<br>");
</script>
</body>
</html>
50
OUTPUT
51
PROGRAM-25
<!DOCTYPE html>
<html>
<head>
<script>
function update()
{
document.getElementById("demo").innerHTML = "New text in p tag using getelementb
yid"
}
</script>
</head>
<body>
<p id="demo">This is sample text in p tag.</p>
<script>
window.alert("Using alert box");
document.write("This output is using document.write:"+5);
console.log(15+6);
</script>
<button onclick="update()">Try it</button>
</body>
</html>
52
OUTPUT
53
PROGRAM-26
<!DOCTYPE html>
<html>
<head>
<title>array functions</title>
</head>
<body>
<script>
var arr=["red","yellow","green"];
arr.push("blue");
document.write("<b>push blue:</b> ")
for(var i=0;i<arr.length;i++)
document.writeln(arr[i]+"\t");
arr.pop();
document.write("<br>");
document.write("<b>pop:</b> ");
for(var i=0;i<arr.length;i++)
document.writeln(arr[i]+"\t");
arr.reverse();
document.write("<br>");
document.write("<b>reverse: </b>");
for(var i=0;i<arr.length;i++)
document.writeln(arr[i]+"\t");
arr.sort();
document.write("<br>");
document.write("<b>sort: </b>");
for(var i=0;i<arr.length;i++)
document.writeln(arr[i]+"\t");
arr.splice(0,2,["purple","orange","white"]);
document.write("<br>");
document.write("<b>splice(0,2,['purple','orange','white']: </b>");
for(var i=0;i<arr.length;i++)
document.writeln(arr[i]+"\t");
arr.unshift("brown");
document.write("<br>");
document.write("<b>unshift brown:</b> ");
for(var i=0;i<arr.length;i++)
document.writeln(arr[i]+"\t");
</script>
54
</body>
</html>
OUTPUT
55
PROGRAM-27
Write a javascript to find the area of a triangle where lengths of the three of its sides are
5,6,7.
CODE
<html>
<head>
<title>area of triangle</title>
</head>
<body>
<script>
var a=5,b=6,c=7,area=0,s=0;
s=(a+b+c)/2;
area=Math.sqrt(s*(s-a)*(s-b)*(s-c));
document.write("area of triangle is "+Math.round(area));
</script>
</body>
</html>
OUTPUT
56
PROGRAM-28
Write a javascript program to determine whether a given year is leap year in the
Gregorian calendar.
CODE
<html>
<head>
<title>leap year</title>
</head>
<body>
<script>
var year=prompt("enter year: ");
document.write(year+"<br>");
if(year%4==0)
{
document.write("leap year");2012
}
else
{
document.write("Not a leap year");
}
</script>
</body>
</html>
OUTPUT
57
PROGRAM-29
<html>
<head>
<title>multiplication and division</title>
</head>
<body>
<form>
1st number:<input type="number" id="a"><br>
2nd number: <input type="number" id="b"><br>
<input type="button" value=multiply onclick="multiply()">
<input type="button" value=divide onclick="divide()">
</form>
<p>The result is </p>
<p id="result"></p>
<script>
function multiply()
{
num1=document.getElementById("a").value;
num2=document.getElementById("b").value;
document.getElementById("result").innerHTML=num1*num2;
}
function divide()
{
num1=document.getElementById("a").value;
num2=document.getElementById("b").value;
document.getElementById("result").innerHTML=num1/num2;
}
</script>
</body>
</html>
58
OUTPUT
59
PROGRAM-30
<html>
<head>
<title>prime number from 1 to 100</title>
</head>
<body>
<script>
for (var counter = 1; counter <= 100; counter++)
{
var notPrime = false;
for (var i = 2; i <= counter; i++)
{
if ((counter%i)==0 && i!=counter)
{
notPrime = true;
}
}
if (notPrime == false)
{
document.write(counter+"<br>");
}
}
</script>
</body>
</html>
60
OUTPUT
61
PROGRAM-31
<!DOCTYPE html>
<head>
<title>String methods</title>
</head>
<body>
<hr>
<label id="label"></label>
<script>
</script>
</body>
</html>
62
OUTPUT
63
PROGRAM-32
<!DOCTYPE html>
<html lang="en">
<head>
<title>Date methods</title>
</head>
<body>
<hr>
<script>
dateObj.setMilliseconds(19987);
</script>
</body>
</html>
64
OUTPUT
65
PROGRAM-33
<html>
<head>
<title>Math objects</title>
</head>
<body>
<script>
var flr,lg,mx,mn,pw,rnd,srt,ep,as,cl;
flr=Math.floor(9.2);
lg=Math.log(2.718282);
mx=Math.max(10,20);
mn=Math.min(10,20);
pw=Math.pow(2,6);
rnd=Math.round(9.75);
srt=Math.sqrt(400);
ep=Math.exp(1);
as=Math.abs(-23);
cl=Math.ceil(9.2);
document.write("<br>"+"floor is "+flr);
document.write("<br>"+"log is "+lg);
document.write("<br>"+"sqrt is "+srt);
document.write("<br>"+"max is "+mx);
document.write("<br>"+"min is "+mn);
document.write("<br>"+"absolute value is "+as);
document.write("<br>"+"ceil is "+cl);
document.write("<br>"+"round is "+rnd);
document.write("<br>"+"power is "+pw);
document.write("<br>"+"exponent is "+ep);
</script>
</body>
</html>
66
OUTPUT
67
PROGRAM-34
<html>
<head>
<title>Window object</title>
</head>
<body>
<script>
window.alert("window object");
var n=window.prompt("enter number ");
window.document.write("hello");
var w;
function openwin()
{
w=window.open("prog 30.html",height=100,width=200);
}
function closewin()
{
w.window.close();
}
function focuswin()
{
w.window.focus();
}
function blurwin()
{
w.window.blur();
}
</script>
<p>hello my name is sahil pathak</p>
<button id="open" onclick=openwin()>open window</button>
<button id="close" onclick=closewin()>close window</button>
<button id="focus" onclick=focuswin()>focus window</button>
<button id="blur" onclick=blurwin()>blur window</button>
</body>
</html>
68
OUTPUT
69
when blur window button is pressed
PROGRAM-35
<!DOCTYPE html>
<html lang="en">
<head>
<title>event handling</title>
<style>
#div1 {
background-color: whitesmoke;
border: 1 solid black;
height: 500;
width: 500;
text-align: center;
padding: 10px;
}
</style>
</head>
<body>
<table>
<tr>
<td><input type="button" value="HoverEvent" onmouseover="overBut
ton(this)" onmouseout="outButton(this)"></td>
</tr>
<label for="bg_color">Select backgroundColor : </label>
<select name="" id="bg_color" onchange="changeBackground(this)">
<option selected>--background--</option>
<option value="red">red</option>
<option value="blue">blue</option>
<option value="brown">brown</option>
</select>
70
</table>
<div id="div1" onmouseover="changeText(this)" onmouseout="revertText(thi
s)">
- Mouse Hover Effect -
</div>
<script>
function changeText(obj) {
obj.innerHTML = "HELLO!";
}
function revertText(obj) {
obj.innerHTML = "- Mouse Hover Effect -";
}
function changeBackground(obj) {
window.document.body.style.backgroundColor = obj.value;
}
function overButton(b) {
b.value = "Hovering";
}
function outButton(b) {
b.value = "Hover Event";
}
</script>
</body>
</html>
OUTPUT
71
PROGRAM-36
WAP to demonstrate various methods of document object in DOM HTML to find HTML
elements.
CODE
<html>
<head>
<title> changing content of p</title>
</head>
<body>
<p><b>changing element by id</b></p>
<p id="p1">hello world</p>
<p><b>changing element by class name</b></p>
<p class="c1">sahil pathak </p>
<p id="class"></p>
<p><b>changing element by Query selector</b></p>
<p id="query"></p>
<script>
document.getElementById("p1").innerHTML="Sahil Pathak by id";
var x=document.getElementsByClassName("c1");
document.getElementById("class").innerHTML="selected by class: "+x[0]
.innerHTML;
var y=document.querySelectorAll("p.c1");
document.getElementById("query").innerHTML="query slector all: "+y[0]
.innerHTML;
</script>
</body>
</html>
72
OUTPUT
73
PROGRAM-37
<html>
<head>
<title>attribute of image DHTML</title>
</head>
<body>
<img src="html.jpg" alt="html image" id="img1" onclick=changeimage()>
</body>
<script>
function changeimage()
{
document.getElementById("img1").src="css.png";
}
</script>
</html>
OUTPUT
ON IMAGE CLICK
74
PROGRAM-38
<html>
<head>
<title>events dhtml</title>
</head>
<body onload=bload() >
<div ondblclick="mclick(this)" onmousedown="mdown(this)" onmouseup="mup(
this)" onmouseover="mover(this)" onmouseout="mout(this)"
style="background-color:#D94A38;width:90px;height:20px;padding:40px;">
Click Me</div>
<p id="p2">date:</p>
<p id="p1"></p>
enter your name: <input type="text" id="inp1" onchange="change()" onfocu
s="focus1(this)">
<script>
function mclick(obj)
{
obj.style.backgroundColor = "green";
obj.innerHTML = "clicked";
}
function mover(obj)
{
obj.style.backgroundColor = "pink";
obj.innerHTML = "over Me";
}
function mout(obj)
{
obj.style.backgroundColor="yellow";
obj.innerHTML="mouse out";
}
function mdown(obj)
{
obj.style.backgroundColor="gray";
obj.innerHTML="mouse down";
}
function mup(obj)
{
75
obj.style.backgroundColor="brown";
obj.innerHTML="mouse up";
}
function change()
{
var x=document.getElementById("inp1");
x.value=x.value.toUpperCase();
}
function focus1(x)
{
x.style.background = "yellow";
}
function bload(x)
{
alert("events using dhtml");
}
document.getElementById("p2").addEventListener("click",displaydate);
function displaydate()
{
document.getElementById("p1").innerHTML=Date();
}
</script>
</body>
</html>
76
OUTPUT
77
PROGRAM-39
<html>
<head>
<title>bubbling and capturing</title>
<style>
#myDiv1, #myDiv2 {
background-color: green;
padding: 50px;
}
#myP1, #myP2 {
background-color: white;
font-size: 20px;
border: 1px solid;
padding: 20px;
}
</style>
</head>
<body>
<div id="myDiv1">
<h2>Bubbling:</h2>
<p id="myP1">Click </p>
</div><br>
<div id="myDiv2">
<h2>Capturing:</h2>
<p id="myP2">Click </p>
</div>
<script>
document.getElementById("myP1").addEventListener("click", function()
{
alert("You clicked the child element!");
}, false);
document.getElementById("myDiv1").addEventListener("click", function()
{
alert("You clicked the parent element!");
}, false);
document.getElementById("myP2").addEventListener("click", function()
78
{
alert("You clicked the child element!");
}, true);
document.getElementById("myDiv2").addEventListener("click", function()
{
alert("You clicked the parent element!");
}, true);
</script>
</body>
</html>
OUTPUT
BUBBLING OUTPUT
CAPTURING OUTPUT
79
PROGRAM-40
Wap to show
1. Transition effects
CODE
<html>
<head>
<style>
div{
width: 100px;
height: 100px;
background:greenyellow;
transition: width 5s;
}
#div1 {transition-timing-function: linear;}
#div2 {transition-timing-function: ease;}
#div3 {transition-timing-function: ease-in;}
#div4 {transition-timing-function: ease-out;}
#div5 {transition-timing-function: ease-in-out;}
div:hover {
width: 400px;
}
</style>
</head>
<body>
<div id="divl">linear</div><br>
<div id="div2">ease</div><br>
<div id="div3">ease-in</div><br>
<div id="div4">ease-out</div><br>
<div id="div5">ease-in-out</div><br>
<p>Hover over the div elements above, to see the different speed curves.</p>
</body>
</html>
80
OUTPUT
81
2. Filtering effects on an image of your choice.
<html>
<head>
<style>
img
{
float:left;
}
.blur
{
filter:blur(4px);
}
.brightness
{
filter:brightness(0,30);
}
.contrast
{
filter:contrast(0);
}
.grayscale
{
filter:grayscale(100%);
}
.huerotate
{
filter:hue-rotate(90deg);
}
.invert
{
filter:invert(100%);
}
.opacity
{
filter:opacity(50%);
}
.saturate
{
filter:saturate(7);
82
}
.sepia
{
filter:sepia(100%);
}
.shadow
{
filter:drop-shadow(8px 8px 10px green);
}
</style>
</head>
<body>
<p>original</p>
<img src="flower1.jfif" alt="flower" width="100" height="100">
<p>blur</p>
<img class="blur" src="flower1.jfif" alt="flower" width="100" height="100">
<p>brightness</p>
<img class="brightness" src="flower1.jfif" alt="flower" width="100" height="100">
<p>contrast</p>
<img class="contrast" src="flower1.jfif" alt="flower" width="100" height="100">
<p>grayscale</p>
<img class="grayscale" src="flower1.jfif" alt="flower" width="100" height="100">
<p>huerotate</p>
<img class="huerotate" src="flower1.jfif" alt="flower" width="100" height="100">
<p>invert</p>
<img class="invert" src="flower1.jfif" alt="flower" width="100" height="100">
<p>opacity</p>
<img class="opacity" src="flower1.jfif" alt="flower" width="100" height="100">
<p>saturate</p>
<img class="saturate" src="flower1.jfif" alt="flower" width="100" height="100">
<p>sepia</p>
<img class="sepia" src="flower1.jfif" alt="flower" width="100" height="100">
<p>shadow</p>
<img class="shadow" src="flower1.jfif" alt="flower" width="100" height="100">
</body>
</html>
83
OUTPUT
84
PROGRAM-41
CODE
<!DOCTYPE html>
<html>
<body>
<p><b>eval function: </b></p>
<p id="eval"></p>
<p><b>escape:</b> </p>
<p id="escape"></p>
<p><b>isNaN:</b></p>
<p id="isnan"></p>
<p><b>parseint:</b> </p>
<p id="parseint"></p>
<p><b>parsefloat:</b> </p>
<p id="parsefloat"></p>
<p><b>unescaped:</b> </p>
<p id ="escaped"></p>
<p id="unescaped"></p>
<script>
var x = 10;
var y = 20;
var a = eval("x * y") + "<br>";
var c = eval("x + 17") + "<br>";
var res = a + c;
document.getElementById("eval").innerHTML = res;
var x=escape("hello! my name is sahil");
document.getElementById("escape").innerHTML = x;
var a=isNaN("hello")+" :hello <br>" ;
var b=isNaN(123)+" :123 <br>";
document.getElementById("isnan").innerHTML=a+b;
var a = parseFloat("10.00")+": 10.00";
var b = parseFloat("10.33")+": 10.33";
var c = parseFloat("34 45 66")+": 34 45 66";
var d = parseFloat("40 years")+": 40 years";
var e = parseFloat("He was 40")+": He was 40";
85
document.getElementById("parsefloat").innerHTML =
a + "<br>" +
b + "<br>" +
c + "<br>" +
d + "<br>" +
e;
var a = parseInt("10.00")+": 10.00";
var b = parseInt("10.33")+": 10.33";
var c = parseInt("34 45 66")+": 34 45 66";
var d = parseInt("40 years")+": 40 years";
var e = parseInt("He was 40")+": He was 40";
document.getElementById("parseint").innerHTML =
a + "<br>" +
b + "<br>" +
c + "<br>" +
d + "<br>" +
e;
var y=unescape(x);
document.getElementById("escaped").innerHTML = x;
document.getElementById("unescaped").innerHTML = y;
</script>
</body>
</html>
86
OUTPUT
Program 42
<html>
<head>
<title>Boolean Objects</title>
</head>
<body>
<h3><u>Boolean objects property</u></h3>
<p><b>constructor</b></p>
<p id="const"></p>
<p><b>prototype</b></p>
<p id="proto"></p>
<h3><u>Boolean objects Methods</u></h3>
<p><b>toString()</b></p>
<p id="tos"></p>
<p><b>valueOf()</b></p>
<p id="valof"></p>
<script>
var bool = false;
document.getElementById("const").innerHTML = bool.constructor;
Boolean.prototype.myColor = function()
{
if (this.valueOf() == true)
{
return "green";
}
else
{
return "red";
}
}
var a = true;
document.getElementById("proto").innerHTML = a.myColor();
87
var bool = true;
var x = bool.toString()
document.getElementById("tos").innerHTML = typeof x;
var bool = false;
var x = bool.valueOf();
document.getElementById("valof").innerHTML = x;
</script>
</body>
</html>
88
PROGRAM 43
<html>
<head>
<title>Number Objects</title>
</head>
<body>
<h3><u>Number objects property</u></h3>
<p><b>constructor</b></p>
<p id="const"></p>
<p><b>max value</b></p>
<p id="mv"></p>
<p><b>min value</b></p>
<p id="mnv"></p>
<p><b>prototype</b></p>
<p id="proto"></p>
<p><b>prototype</b></p>
<p id="proto"></p>
<h3><u>Number objects Methods</u></h3>
<p><b>isFinite()</b></p>
<p id="isf"></p>
<p><b>isSafeInteger()</b></p>
<p id="issi"></p>
<p><b>toExponential()</b></p>
<p id="toe"></p>
<p><b>toFixed()</b></p>
<p id="tof"></p>
<p><b>toPrecision()</b></p>
<p id="top"></p>
<p><b>toString()</b></p>
<p id="tos"></p>
<script>
var num = 134.5;
document.getElementById("const").innerHTML = num.constructor;
89
document.getElementById("mv").innerHTML = Number.MAX_VALUE;
document.getElementById("mnv").innerHTML = Number.MIN_VALUE;
Number.prototype.myMethod = function()
{
return this.valueOf() / 2;
}
var n = 55;
document.getElementById("proto").innerHTML = n.myMethod();
var res = "";
res = res + Number.isFinite(123) + ": 123<br>";
res = res + Number.isFinite(-1.23) + ": -1.23<br>";
res = res + Number.isFinite(5-2) + ": 5-2<br>";
res = res + Number.isFinite(0) + ": 0<br>";
res = res + Number.isFinite('123') + ": '123'<br>";
res = res + Number.isFinite('Hello') + ": 'Hello'<br>";
res = res + Number.isFinite(Infinity) + ": Infinity<br>";
document.getElementById("isf").innerHTML = res;
var res1 = "";
res1 = res1 + Number.isSafeInteger(123) + ": 123<br>";
res1 = res1 + Number.isSafeInteger(-123) + ": -123<br>";
res1 = res1 + Number.isSafeInteger(Math.pow(2, 53)) + ": 2<sup>53</s
up><br>";
res1 = res1 + Number.isSafeInteger(Math.pow(2, 53) - 1) + ": 2<sup>5
3</sup> - 1<br>";
res1 = res1 + Number.isSafeInteger(Infinity) + ": Infinity<br>";
res1 = res1 + Number.isSafeInteger(-Infinity) + ": -Infinity<br>";
document.getElementById("issi").innerHTML = res1;
var num = 5.56789;
var n = num.toExponential();
document.getElementById("toe").innerHTML = n+" :5.56789";
var num = 5.56789;
var n = num.toFixed(2);
document.getElementById("tof").innerHTML = n+" :5.56789";
document.write("<b>toLocaleString()</b><br>");
var num = new Number(1000000).toLocaleString("fi-FI");
document.write(num+" :1000000");
var num = 13.3714;
90
document.getElementById("top").innerHTML = num.toPrecision(2)+ " : "
+num;
var num = 15;
var n = num.toString()+" : "+ num;
document.getElementById("tos").innerHTML = n;
</script>
</body>
</html>
91
PROGRAM-44
<html>
<head>
<title>Regular Expression</title>
</head>
<body>
<p id="p1">
</p>
<script>
var x = document.getElementById("p1");
var str = "hello lorenzo loves\n 99986 lotte choco pie &*%!!";
x.innerHTML += "<br/><b>String: </b>" + str + "<br/><br>";
x.innerHTML += "<b>Result: </b><br>";
var pat1 = /lo*/g;
x.innerHTML += "<b>" +pat1+" : </b>"+ str.match(pat1) + "<br/>";
var pat2 = /[l-p]/g;
x.innerHTML += "<b>" +pat2+" : </b>"+str.match(pat2) + "<br/>";
var pat3 = /otte/g;
x.innerHTML += "<b>" +pat3+" : </b>"+str.match(pat3) + "<br/>";
x.innerHTML +="<b>" +pat3+" search : </b>"+ str.search(pat3) + "<br/>";
var pat4 = /(l|i)/;
x.innerHTML += "<b>" +pat4+" : </b>"+str.match(pat4) + "<br/>";
var pat5 = /e+/g;
x.innerHTML += "<b>" +pat5+" : </b>"+str.match(pat5) + "<br/>";
x.innerHTML += "<b>" +pat5+" search : </b>"+str.search(pat5) + "<br/>";
var pat6 = /c/g;
x.innerHTML += "<b>" +pat6+" : </b>"+str.match(pat6) + "<br/>";
var pat7 = /\d/g;
x.innerHTML += "<b>" +pat7+" : </b>"+str.match(pat7) + "<br/>";
var pat8 = /\w/g;
x.innerHTML += "<b>" +pat8+" : </b>"+str.match(pat8) + "<br/>";
var pat9 = /\W/g;
x.innerHTML += "<b>" +pat9+" : </b>"+str.match(pat9) + "<br/>";
var pat10 = /\D/g;
x.innerHTML += "<b>" +pat10+" : </b>"+str.match(pat10) + "<br/>";
var pat11 = /e{9}/g;
x.innerHTML += "<b>" +pat11+" : </b>"+str.match(pat11) + "<br/>";
pat12 = /l{2}/g;
x.innerHTML += "<b>" +pat12+" : </b>"+str.match(pat11) + "<br/>";
92
</script>
</body>
</html>
93
PROGRAM 45
<?xml version="1.0"?>
<!DOCTYPE STUDENT
[
<!ELEMENT STUDENT (NAME,ROLLNO,DOB,ADDRESS)>
<!ELEMENT NAME (#PCDATA)>
<!ELEMENT ROLLNO (#PCDATA)>
<!ELEMENT DOB (#PCDATA)>
<!ELEMENT ADDRESS (#PCDATA)>
]>
<STUDENT>
<NAME>Sahil Pathak</NAME>
<ROLLNO> 08829802019 </ROLLNO>
<DOB> 08-04-2001 </DOB>
<ADDRESS>Ashok Vihar,Delhi</ADDRESS>
</STUDENT>
94