CSS Codes
CSS Codes
(b) List ways of protecting your web page and describe any one of them.
Ans.
1)Hiding your source code
2)Disabling the right MouseButton
<!DOCTYPE html>
<html>
<head>
<title>Disable Right Click</title>
</head>
<body>
<h2>Right-Click Disabled</h2>
<p>Try right-clicking on this page.</p>
<script>
document.addEventListener("contextmenu", function(event) {
event.preventDefault();
alert("Right-click is disabled on this page.");
});
</script>
</body>
</html>
3) Hiding JavaScript
4) Concealing E-mail address.
<script>
let textElement = document.getElementById("text");
textElement.addEventListener("mouseover", function() {
textElement.style.color = "blue";
textElement.style.fontSize = "24px";
});
textElement.addEventListener("mouseout", function() {
textElement.style.color = "black";
textElement.style.fontSize = "20px";
});
</script>
</body>
</html>
(e) Write a Java script to modify the status bar using on MouseOver and on
MouseOut with links. When the user moves his mouse over the link, it will
display “MSBTE” in the status bar. When the user moves his mouse away
from the link the status bar will display nothing.
Ans.
<!DOCTYPE html>
<html>
<head>
<title>Status Bar Example</title>
<style>
#statusBar {
height: 20px;
margin-top: 20px;
background-color: #f0f0f0;
border: 1px solid #ccc;
padding: 5px;
font-family: Arial, sans-serif;
}
</style>
</head>
<body>
<h2>Simulated Status Bar Example</h2>
<p>
<a href="https://www.example.com"
onmouseover="showStatus('MSBTE')"
onmouseout="showStatus('')">Hover over this link</a>
</p>
<div id="statusBar"></div>
<script>
// Function to update the simulated status bar
function showStatus(message) {
document.getElementById("statusBar").innerText = message;
}
</script>
</body>
</html>
5. Attempt any TWO of the following : 12
(b) Describe, how to read cookie value and write a cookie value. Explain with
example.
Ans.
(c) Write a Java script that displays textboxes for accepting name & email ID & a
submit button. Write Java script code such that when the user clicks on submit
button
(1) Name Validation
(2) Email ID validation
Ans.
<!DOCTYPE html>
<html>
<head>
<title>Form Validation</title>
</head>
<body>
<h2>User Input Validation</h2>
<form id="userForm">
<label for="name">Name:</label>
<input type="text" id="name" placeholder="Enter your name"><br><br>
<label for="email">Email ID:</label>
<input type="text" id="email" placeholder="Enter your email"><br><br>
<button type="button" onclick="validateForm()">Submit</button>
</form>
<p id="message" style="color: red;"></p>
<script>
function validateForm() {
let name = document.getElementById("name").value;
let email = document.getElementById("email").value;
let message = "";
// Name validation: must not be empty and should contain only alphabets
if (name === "" || !/^[a-zA-Z\s]+$/.test(name)) {
message = "Please enter a valid name (letters and spaces only).";
}
// Email validation: must follow the standard email format
else if (email === "" || !/^\S+@\S+\.\S+$/.test(email)) {
message = "Please enter a valid email address.";
}
// If both validations pass
else {
message = "Form submitted successfully!";
document.getElementById("message").style.color = "green";
}
CSS Summer 22
<script>
function changeContent() {
// Change the content of the window
document.getElementById("content").innerText = "The content has been changed
dynamically!";
}
</script>
</body>
</html>
(a) Write a javascript program to validate user accounts for multiple set of user
ID and password (using swith case statement).
Ans.
(d) Design a webpage that displays a form that contains an input for user name
and password. User is prompted to enter the input user name and password
and password become value of the cookies. Write the javascript function for
storing the cookies.
Ans.
<!DOCTYPE html>
<html>
<head>
<title>Store Cookies Example</title>
</head>
<body>
<h2>Login Form</h2>
<form onsubmit="storeCookies(); return false;">
<label for="username">Username:</label><br>
<input type="text" id="username" name="username" required><br><br>
<label for="password">Password:</label><br>
<input type="password" id="password" name="password" required><br><br>
<button type="submit">Submit</button>
</form>
<script>
// Function to store username and password in cookies
function storeCookies() {
const username = document.getElementById("username").value;
const password = document.getElementById("password").value;
// Store the values in cookies
document.cookie = `username=${username}; path=/`;
document.cookie = `password=${password}; path=/`;
<form id="cookieForm">
<label for="cookieName">Cookie Name:</label><br>
<input type="text" id="cookieName" required><br><br>
<p id="cookieResult"></p>
<script>
// Create a cookie
function createCookie() {
const name = document.getElementById("cookieName").value;
const value = document.getElementById("cookieValue").value;
document.cookie = `${name}=${value}; path=/`; // Setting cookie with path
document.getElementById("cookieResult").innerText = `Cookie created: ${name}=$
{value}`;
}
// Read a cookie
function readCookie() {
const name = document.getElementById("cookieName").value;
const cookies = document.cookie.split("; ");
let cookieValue = null;
if (cookieValue) {
document.getElementById("cookieResult").innerText = `Cookie found: $
{name}=${cookieValue}`;
} else {
document.getElementById("cookieResult").innerText = `Cookie not found: $
{name}`;
}
}
// Update a cookie
function updateCookie() {
const name = document.getElementById("cookieName").value;
const value = document.getElementById("cookieValue").value;
document.cookie = `${name}=${value}; path=/`; // Update cookie
document.getElementById("cookieResult").innerText = `Cookie updated: ${name}=$
{value}`;
}
// Delete a cookie
function deleteCookie() {
const name = document.getElementById("cookieName").value;
document.cookie = `${name}=; path=/; expires=Thu, 01 Jan 1970 00:00:00 UTC`; //
Set an expired date to delete cookie
document.getElementById("cookieResult").innerText = `Cookie deleted: ${name}`;
}
</script>
</body>
</html>
(c) Write a javascript program to calculate add, sub, multiplication and division
of two number (input from user). Form should contain two text boxes to input
numbers of four buttons for addition, subtraction, multiplication and division.
Ans.
(d) State what is regular expression. Explain its meaning with the help of a
suitable example.
Ans.
(b) Write a javascript function that accepts a string as a parameter and find the
length of the string.
Ans.
(c) Write a javascript program to validate email ID of the user using regular
expression.
Ans.
(d) Write a javascript program to design HTML page with books information in
tabular format, use rollovers to display the discount information.
Ans.
(e) List ways of protecting your webpage and describe any one of them.
Ans.
(b) Develop javascript to convert the given character to unicode and vice-versa.
Ans.
(c) Write a javascript program to create a silde show with the group of six
images, also simulate the next and previous transition between slides in your
javascript.
Ans.
(b) Write a javascript to create option list containing list of images and then
display images in new window as per selection.
Ans.
(c) Write a javascript function to generate Fibonacci series till user defined limit.
Ans.
CSS Summer 22
(a) Write a javascript program to validate user accounts for multiple set of user
ID and password (using swith case statement).
Ans.
(c) Write a javascript program to demonstrate java intrinsic function.
Ans.
(d) Design a webpage that displays a form that contains an input for user name
and password. User is prompted to enter the input user name and password
and password become value of the cookies. Write the javascript function for
storing the cookies.
Ans.
(c) Write a javascript program to calculate add, sub, multiplication and division
of two number (input from user). Form should contain two text boxes to input
numbers of four buttons for addition, subtraction, multiplication and division.
Ans.
(d) State what is regular expression. Explain its meaning with the help of a
suitable example.
Ans.
(b) Write a javascript function that accepts a string as a parameter and find the
length of the string.
Ans.
(c) Write a javascript program to validate email ID of the user using regular
expression.
Ans.
(d) Write a javascript program to design HTML page with books information in
tabular format, use rollovers to display the discount information.
Ans.
(e) List ways of protecting your webpage and describe any one of them.
Ans.
(c) Write a javascript program to create a silde show with the group of six
images, also simulate the next and previous transition between slides in your
javascript.
Ans.
(b) Write a javascript to create option list containing list of images and then
display images in new window as per selection.
Ans.
(c) Write a javascript function to generate Fibonacci series till user defined limit.
Ans.
CSS Winter 22
(b) Write a JavaScript program that will remove the duplicate element from an
array
Ans.
(c) Write a JavaScript program that will display list of student in ascending order
according to the marks & calculate the average performance of the class.
Ans.
(d) Write and explain a string functions for converting string to number and
number to string.
Ans.
(c) Write a JavaScript function to merge two array & removes all duplicate
values.
Ans.
(d) Write a JavaScript function that will open new window when the user will
clicks on the button.
Ans.
(b) Write a JavaScript program that will create pull-down menu with three
options. Once the user will select the one of the options then user will
redirected to that website.
Ans.
(b) Write a webpage that displays a form that contains an input for username &
password. User is prompted to entre the input & password & password
becomes the value of the cookie. Write a JavaScript function for storing the
cookie. It gets executed when the password changes
Ans.
Chapter 1 & Chapter 2 are linked to the webpage Ch1 HTML & Ch2.html
respectively. When user click on these links corresponding data appears in
FRAME3.
CSS Winter 23
(b) Write a JavaScript that accepts user’s first name and domain name of
organization from user. The JavaScript then forms email address as
<firstname@domain name> and displays the results in the browser window.
Ans.
(c) Differentiate between substring() and substr() method of a string class. Give
suitable example of each.
Ans.
(d) State what is a cookie ? Explain its need. State characteristics of persistent
cookies
Ans.
(b) List and state various properties of a window object. Write a JavaScript that
opens a new popup window with message “WELCOME To SCRIPTING”
when the page loads and a new popup window displaying message “FUN
WITH SCRIPTING” when the page unloads.
Ans.
(c) Write an HTML script that displays names of different brands of Laptop and
an image by default as :
When the mouse moves over the specific brand name the script must display
the image of respective Laptop in the adjacent box.
Ans.
(d) Give syntax of and explain the use of SetTime Out( ) function with the help of
suitable example.
Ans.
(e) State the use of hiding the JavaScript. Explain the steps needed to accomplish
it and describe the process.
5. Attempt any TWO :
(a) Write a JavaScript that demonstrates use of floating menu alongwith
respective HTML script.
Ans.
(b) Write a JavaScript that sets a crawling status bar message to the webpage.
Message is “Welcome to the Mystic World of JavaScript”.
The message must start crawling when the webpage gets loaded.
Ans.
(c)
(i) Design frameset tag for representing following layout :
(ii) List any three properties of regular expression objects and state their
use
Ans.
CSS Summer 24
b) Explain setter and getter properties in JavaScript with the help of suitable example.
Ans.
a) State what is frame? Explain how it can be created with suitable example.
Ans.
b) Explain the steps to create floating menu and chain select menu
Ans.
a) Write HTML script that displays textboxes for accepting username and password.
Write proper JavaScript such that when the user clicks on submit button
i) All textboxes must get disabled and change the color to 'RED' and with respective
labels.
ii) Prompt the error message if the password is less than six characters.
Ans.
b) Write a webpage that displays a form that contains an input for students rollno and
names user is prompted to enter the input student rollno and name and rollno becomes
value of the cookie.
Ans.
c) Write a JavaScript to create rollover effect that involves text and images. When the
user places his or her mouse pointer over a book title, the corresponding book image
appears.
Ans.
6. Attempt any TWO of the following:12
a) Explain following form control/elements with example Button, Text, TextArea, Select
Checkbox, Form.
Ans.
b) Write a JavaScript for protecting web page by implementing the following steps:
i) Hiding your source code
ii) Disabling the right MouseButton
iii) Hiding JavaScript
Ans.
c) Develop a JavaScript to create rotating Banner Ads with URL links.
Ans.