Professional Documents
Culture Documents
Full Stack Mid Term
Full Stack Mid Term
xhr.onerror = function () {
console.error("Network error occurred");
};
xhr.send();
</script>
</body>
</html>
Data.json file :
{
"name": "John Doe",
"email": "john@example.com",
"age": 30,
"isStudent": false,
"address": {
"street": "123 Main St",
"city": "Cityville",
"zipcode": "12345"
},
"hobbies": ["reading", "hiking", "gaming"]
}
OUTPUT
PRACTICAL-2
<mfrac bevelled="true">
<mi>x</mi>
<mi>y</mi>
</mfrac>
<mo>=</mo>
<mn>0</mn>
</math>
</body>
</html>
OUTPUT
PRACTICAL-3
3.Design a website and use the geolocation API to track the user current
location.
Source Code :
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Get User Location</title>
</head>
<body>
<button onclick="getLocation()">Click Here</button>
<p id="p1">Coordinates Are : </p>
<script>
var x = document.getElementById("p1");
function getLocation() {
if (navigator.geolocation) {
navigator.geolocation.getCurrentPosition(showPosition);
} else {
x.innerHTML = "Geolocation is not supported by this browser.";
}
}
function showPosition(position) {
x.innerHTML = "Latitude: " + position.coords.latitude + "<br>Longitude: " +
position.coords.longitude;
}
</script>
</body>
</html>
OUTPUT
PRACTICAL-4
4.Write a program to drag an image from one location and drop into some other
location in the web page.
Source Code :
<!DOCTYPE HTML>
<html>
<head>
<style>
#div1, #div2 {
float: left;
width: 100px;
height: 35px;
margin: 10px;
padding: 10px;
border: 1px solid rgb(8, 233, 249);
}
</style>
<script>
function allowDrop(ev) {
ev.preventDefault();
}
function drag(ev) {
ev.dataTransfer.setData("image", ev.target.id);
}
function drop(ev) {
ev.preventDefault();
var data = ev.dataTransfer.getData("image");
ev.target.appendChild(document.getElementById(data));
}
</script>
</head>
<body>
OUTPUT
PRACTICAL-5
Source Code :
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Canvas Example</title>
</head>
<body>
<script>
ctx.fillStyle = 'red';
ctx.fillStyle = 'yellow';
ctx.fillStyle = 'green';
ctx.beginPath();
ctx.arc(10, 10, 10, 0, 2 * Math.PI);
ctx.fillStyle = 'blue';
ctx.fill();
ctx.beginPath();
ctx.fillStyle = 'orange';
ctx.fill();
</script>
</body></html>
OUTPUT
PRACTICAL-6
6.Write a program to group circle and rectangle and render 3 times at different
positions inside SVG area.
Source Code :
<!DOCTYPE html>
<html>
<head>
<title>SVG Grouping Example</title>
</head>
<body>
<svg width="400" height="200" xmlns="http://www.w3.org/2000/svg">
<g id="shapeGroup">
<!-- Circles -->
<circle cx="50" cy="50" r="20" fill="blue" />
<circle cx="100" cy="50" r="20" fill="green" />
<circle cx="150" cy="50" r="20" fill="red" />
<script>
const shapeGroup = document.getElementById("shapeGroup");
const group1 = shapeGroup.cloneNode(true);
group1.setAttribute("transform", "translate(50, 100)");
OUTPUT
PRACTICAL-7
7.Write a program to binds the "sample" animation to the <div> element. The
animation will last for 4 seconds, and it will gradually change the background-
color of the <div> element from "red to green and “green to yellow", and it
retain the style values from the last keyframe when the animation ends.
Source Code :
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<style>
.color-changing-div {
width: 200px;
height: 200px;
background-color: red;
animation: colorChange 10s forwards;
}
@keyframes colorChange {
0% {
background-color: red;
}
50% {
background-color: green;
}
100% {
background-color: yellow;
}
}
</style>
</head>
<body>
<div class="color-changing-div" id="sample"></div>
<script>
const sampleDiv = document.getElementById("sample");
sampleDiv.addEventListener("animationend", () => {
sampleDiv.style.backgroundColor = "yellow";
});
</script>
</body>
</html>
OUTPUT
PRACTICAL-8
Source Code :
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<style>
.transform-element {
width: 100px;
height: 100px;
background-color: blue;
transition: transform 0.5s ease, left 0.5s ease, top 0.5s ease;
}
.transformed {
transform: rotate(60deg);
left: 200px;
top: 300px;
}
</style>
</head>
<body>
<div class="transform-element" id="element"></div>
<script>
const element = document.getElementById("element");
element.addEventListener("mouseover", () => {
element.classList.add("transformed");
});
element.addEventListener("mouseout", () => {
element.classList.remove("transformed");
});
</script>
</body>
</html>
OUTPUT