Lab Manual_KIT451_2021_22_Even
Lab Manual_KIT451_2021_22_Even
Lab Manual_KIT451_2021_22_Even
LAB MANUAL
1
.
INDEX
2
Date PROGRAM: 1
1.1 OBJECTIVE:
1.2 CODE
1.3 OUTPUT
RESULT
A simple html file has been created with the use of different tags and the output was verified.
3
DATE PROGRAM: 2
2.1 OBJECTIVE:
To create an html file to link to different html page which contains images, tables, and also
link within a page.
2.2 CODE
4
2.2 OUTPUT
DATE PROGRAM: 3
5
3.1 OBJECTIVE:
To create an html page with different types of frames such as floating frame, navigation frame
& mixed frame.
3.2 PROCEDURE/ALGORITHM/CODE
<!DOCTYPE html>
<html>
<frameset rows="50%,50%">
<frame src="a.jpg">
<frameset cols="25%,75%">
<frame src="b.jpg">
<frame src="c.jpg">
</frameset>
</frameset>
</html>
3.3 OUTPUT
PROGRAM: 4
6
4.1 OBJECTIVE:
To create a registration form as mentioned below. Procedure: Create an html page named as
“registration.html”
4.2 PROCEDURE/ALGORITHM/CODE
7
4.3 OUTPUT
8
9
PROGRAM: 5
5.1 OBJECTIVE
To create an html file by applying the different styles using inline, external &
internal style sheets.
5.2 PROCEDURE/ALGORITHM/CODE
1. External CSS
HTML File
<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" type="text/css" href="mystyle.css">
</head>
<body>
<h1>This is a heading</h1>
<p>This is a paragraph.</p>
</body>
</html>
CSS File
body {
background-color: lightblue;
}
h1 {
color: navy;
margin-left: 20px;
}
2. Internal CSS
<!DOCTYPE html>
<html>
<head>
<style>
body {
background-color: linen;
}
h1 {
color: maroon;
margin-left: 40px;
}
</style>
</head>
<body>
<h1>This is a heading</h1>
<p>This is a paragraph.</p>
10
</body>
</html>
3. Inline CSS
<!DOCTYPE html>
<html>
<body>
<h1 style="color:blue;text-align:center;">This is a heading</h1>
<p style="color:red;">This is a paragraph.</p>
</body>
</html>
5.3 OUTPUT
1. External CSS
2. Internal CSS
3. Inline CSS
11
PROGRAM: 6
6.1 OBJECTIVE
To write a Javascript program to define a user defined function for sorting the values in an
array.
6.2 PROCEDURE/ALGORITHM/CODE
<!DOCTYPE html>
<html>
<body>
<p id="demo"></p>
<script>
// Create and display an array:
var fruits = ["Banana", "Orange", "Apple", "Mango"];
document.getElementById("demo").innerHTML = fruits;
function myFunction() {
// First sort the array
fruits.sort();
// Then reverse it:
fruits.reverse();
document.getElementById("demo").innerHTML = fruits;
}
</script>
</body>
</html>
6.3 OUTPUT
12
PROGRAM: 7
7.1 OBJECTIVE:
To create an html page to explain the use of various predefined functions in a string and math
object in java script.
7.2 PROCEDURE/ALGORITHM/CODE
<!DOCTYPE html>
<html>
<body>
<h2>JavaScript Math.round()</h2>
<p>Math.round(x) returns the value of x rounded to its nearest integer:</p>
<p id="demo"></p>
<script>
document.getElementById("demo").innerHTML = Math.round(4.4);
</script>
</body>
</html>
7.3 OUTPUT
13
PROGRAM: 8
8.1 OBJECTIVE:
To create an html page to explain the use of various predefined functions in a array &
Date object in Javascript.
8.2 PROCEDURE/ALGORITHM/CODE
<!DOCTYPE html>
<html>
<body>
<h2>JavaScript Arrays</h2>
<p id="demo"></p>
<script>
var cars = ["SWIFT", "Volvo", "BMW"];
document.getElementById("demo").innerHTML = cars;
</script>
</body>
</html>
8.3 OUTPUT
14
PROGRAM: 9
9.1 OBJECTIVE:
9.2 PROCEDURE/ALGORITHM/CODE
<!DOCTYPE html>
<html>
<body>
<h2>JavaScript Error Handling</h2>
<p>This example demonstrates how to use <b>catch</b> to diplay an error.</p>
<p id="demo"></p>
<script>
try {
adddlert("Welcome guest!");
}
catch(err) {
document.getElementById("demo").innerHTML = err.message;
}
</script>
</body>
</html>
9.3 OUTPUT
15
PROGRAM: 10
10.1 OBJECTIVE:
To display the calendar using javascript code by getting the year from the user.
10.2 PROCEDURE/ALGORITHM/CODE
<html>
<head>
<title>JavaScript calendar</title>
<script>
function displayCalendar(){
var nextMonth = month+1; //+1; //Used to match up the current month with the correct start date.
var prevMonth = month -1;
var day = dateNow.getDate();
var year = dateNow.getFullYear();
16
// used in next loop.
weekdays--;
}
weekdays2++;
counter++;
}
}
</script>
</head>
<body onload="displayCalendar()">
<div id="calendar"></div>
</body>
<style>
.monthPre{
color: gray;
text-align: center;
}
.monthNow{
color: blue;
text-align: center;
17
}
.dayNow{
border: 2px solid black;
color: #FF0000;
text-align: center;
}
.calendar td{
htmlContent: 2px;
width: 40px;
}
.monthNow th{
background-color: #000000;
color: #FFFFFF;
text-align: center;
}
.dayNames{
background: #0FF000;
color: #FFFFFF;
text-align: center;
}
</style>
</html>
10.3 OUTPUT
18
PROGRAM: 11
11.1 OBJECTIVE:
To create a html registration form and to validate the form using javascript code.
11.2 PROCEDURE/ALGORITHM/CODE
<!DOCTYPE html>
<html>
<head>
<script>
function validateForm() {
var x = document.forms["myForm"]["fname"].value;
if (x == "") {
alert("Name must be filled out");
return false;
}
}
</script>
</head>
<body>
<form name="myForm" action="/action_page.php" onsubmit="return validateForm()"
method="post">
Name: <input type="text" name="fname">
<input type="submit" value="Submit">
</form>
</body>
</html>
11.3 OUTPUT
19
PROGRAM: 12
12.1 OBJECTIVE:
To create a html file. To open new window from the current window using javascript.
12.2 PROCEDURE/ALGORITHM/CODE
<!DOCTYPE html>
<html>
<body>
<p>Click the button to open a new window called "MsgWindow" with some text.</p>
<button onclick="myFunction()">Try it</button>
<script>
function myFunction() {
var myWindow = window.open("", "MsgWindow", "width=200,height=100");
myWindow.document.write("<p>This is 'MsgWindow'. I am 200px wide and 100px
tall!</p>");
}
</script>
</body>
</html>
12.3 OUTPUT
20
PROGRAM: 13
13.1 OBJECTIVE:
To create an html page to change the background color for every click of a button using
javascript
13.2 PROCEDURE/ALGORITHM/CODE
<!DOCTYPE html>
<html>
<head>
<style>
#myDIV {
width: 300px;
height: 300px;
background-color: coral;
color: white;
}
</style>
</head>
<body>
<p>Click the "Try it" button to set the backgroundColor property of the DIV element to
"lightblue":</p>
<button onclick="myFunction()">Try it</button>
<div id="myDIV">
<h1>Hello</h1>
</div>
<script>
function myFunction() {
document.getElementById("myDIV").style.backgroundColor = "lightblue";
}
</script>
</body>
</html>
21
13.3 OUTPUT
22
PROGRAM: 14
14.1 OBJECTIVE:
To create an html page with 2 combo box populated with month & year, to display the
calendar for the selected month & year from combo box using javascript.
14.2 PROCEDURE/ALGORITHM/CODE
<!DOCTYPE html>
<html>
<body>
<p>Click the button to display the date after changing the month and day.</p>
<button onclick="myFunction()">Try it</button>
<p id="demo"></p>
<script>
function myFunction() {
var d = new Date();
d.setMonth(4, 20);
document.getElementById("demo").innerHTML = d;
}
</script>
</body>
</html>
14.3 OUTPUT
23
PROGRAM: 15
15.1 OBJECTIVE:
To create a html page to display a new image & text when the mouse comes over the
existing content in the page.
15.2 PROCEDURE/ALGORITHM/CODE
<!DOCTYPE html>
<html>
<body>
<p id="demo" ondblclick="myFunction()">Double-click me to change my text color.</p>
<p>A function is triggered when the p element is double-clicked. The function sets the color of
the p element to red.</p>
<script>
function myFunction() {
document.getElementById("demo").style.color = "red";
}
</script>
</body>
</html>
15.3 OUTPUT
24