CSS Question Bank For Test
CSS Question Bank For Test
Q1. Describe regular expression. Explain search () method used in regular expression with suitable
example(4M)
regular expression tells the browser how to manipulate text rather than numbers
Search() method:
for the specified regular expression in the string. This method returns the index
Example:
<html>
<body>
<script>
function myFunction() {
// input string
var n = str.search(/Morning/i);
document.write(n + '<br>');
var n = str.search(/Morning/);
document.write(n);
myFunction();
</script>
</body>
</html>
Free Study Material Buy Ty Diploma Buy Sy Diploma Whatsapp Group for Study Material
Q2. List ways of protecting your web page and describe any one of them.(4M)
3) Hiding JavaScript
The source code for your web page—including your JavaScript—is stored in the
cache, the part of computer memory where the browser stores web pages that
were requested by the visitor. A sophisticated visitor can access the cache and
However, you can place obstacles in the way of a potential peeker. First, you can
disable use of the right mouse button on your site so the visitor can't access the
View Source menu option on the context menu. This hides both your HTML code
Nevertheless, the visitor can still use the View menu's Source option to display
your source code. In addition, you can store your JavaScript on your web server
instead of building it into your web page. The browser calls the JavaScript from
Using this method, the JavaScript isn't visible to the visitor, even if the visitor
The following example shows you how to disable the visitor's right mouse button
while the browser displays your web page. All the action occurs in the JavaScript
is called any time the visitor clicks the right mouse button while the web page is
The BreakInDetected() function is called if the visitor clicks any button other
Free Study Material Buy Ty Diploma Buy Sy Diploma Whatsapp Group for Study Material
than the left mouse button.
3) Hiding JavaScript
your web server. The external fi le should have the .js fi le extension. The browser
then calls the external file whenever the browser encounters a JavaScript element
in the web page. If you look at the source code for the web page, you'll see
reference to the external .js fi le, but you won't see the source code for the
JavaScript.
The next example shows how to create and use an external JavaScript file. First
you must tell the browser that the content of the JavaScript is located in an
external
file on the web server rather than built into the web page. You do this by assigning
the fi le name that contains the JavaScripts to the src attribute of the <script>
<script src="MyJavaScripts.js"
language="Javascript" type="text/javascript">
Many of us have endured spam at some point and have probably blamed every
merchant we ever patronized for selling our e-mail address to spammers. While
e-mail addresses are commodities, it's likely that we ourselves are the culprits
Here's what happens: Some spammers create programs called bots that surf the
Net looking for e-mail addresses that are embedded into web pages, such as those
placed there by developers to enable visitors to contact them. The bots then strip
these e-mail addresses from the web page and store them for use in a spam attack.
This technique places developers between a rock and a hard place. If they place
their e-mail addresses on the web page, they might get slammed by spammers. If
they don't display their e-mail addresses, visitors will not be able to get in touch
Free Study Material Buy Ty Diploma Buy Sy Diploma Whatsapp Group for Study Material
Q3. Explain text rollover with suitable example.(2M)
Answer: You create a rollover for text by using the onmouseover attribute of the tag, which is the
anchor tag. You assign the action to the onmouseover attribute the same way as you do with <img>
tag.
<HTML>
<head></head>
<Body>
<textarea rows=”2″ cols=”50″ name=”rollovertext” onmouseover=”this.value=’What is
rollover?'”
onmouseout=”this.value=’Rollover means a webpage changes when the user moves his or
her mouse over an object on the page'”></textarea>
</body>
</html>
Q4: Explain open() method of window object with syntax and example.(4M)
Answer: The open() method of window object is used to open a new window and loads the
MyWindow = window.open()
The open() method returns a reference to the new window, which is assigned to
the MyWindow variable. You then use this reference any time that you want to
A window has many properties, such as its width, height, content, and name—to
mention a few. You set these attributes when you create the window by passing
• The first parameter is the full or relative URL of the web page that will appear
• The second parameter is the name that you assign to the window.
• The third parameter is a string that contains the style of the window.
We want to open a new window that has a height and a width of 250 pixels and
displays an advertisement that is an image. All other styles are turned off.
Syntax:
Free Study Material Buy Ty Diploma Buy Sy Diploma Whatsapp Group for Study Material
Example:
<html >
<head>
<script >
function OpenNewWindow() {
location=0,
</script>
</head>
<body>
onclick="OpenNewWindow()"/>
</FORM>
</body>
</html>
Q5: Create a slideshow with the group of three images, also simulate next and previous transition
between slides in your Java Script.
Answer:
<html>
<head>
<script>
count = 0;
function slideshow(status)
Free Study Material Buy Ty Diploma Buy Sy Diploma Whatsapp Group for Study Material
if
(document.images)
count = 0;
if (count < 0)
count = pics.length - 1;
documet.imag1.src = pics[count];
</script>
</head>
<body>
<br>
</body>
</html>
Q6 : 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 links, it will display “MSBTE” in the status bar. When the
user moves his mouse away from the link the status bar will display nothing.(4M)
Answer:
<html>
<head>
Free Study Material Buy Ty Diploma Buy Sy Diploma Whatsapp Group for Study Material
<body>
Free Study Material Buy Ty Diploma Buy Sy Diploma Whatsapp Group for Study Material
<a href="
onMouseOut="window.status='';return true">
MSBTE
</a>
</body>
</html>
Q7: Describe, how to read cookie value and write a cookie value. Explain with
example.
Answer:
Web Browsers and Servers use HTTP protocol to communicate and HTTP is a
session information among different pages. For example, one user registration
ends after completing many pages. But how to maintain users' session
Expires − The date the cookie will expire. If this is blank, the cookie will
Path − The path to the directory or web page that set the cookie. This
may be blank if you want to retrieve the cookie from any directory or
page.
Secure − If this field contains the word "secure", then the cookie may
restriction exists.
Pairs
Storing Cookies
Free Study Material Buy Ty Diploma Buy Sy Diploma Whatsapp Group for Study Material
document.cookie = "key1 = value1;key2 = value2;expires = date";
Here the expires attribute is optional. If you provide this attribute with a valid
date or time, then the cookie will expire on a given date or time and thereafter,
<html>
<head>
<!--
function WriteCookie()
return;
document.cookie="name=" + cookievalue;
//-->
</script>
</head>
<body>
</form>
</body>
</html>
Free Study Material Buy Ty Diploma Buy Sy Diploma Whatsapp Group for Study Material
9. Write a javascript to create a pull-down menu with three options [Google, MSBTE, Yahoo] once
the user will select one of the options then user will be redirected to that site.
Answer:
<html>
<head>
<title>HTML Form</title>
function getPage(choice)
page=choice.options[choice.selectedIndex].value;
if(page != "")
window.location=page;
</script>
</head>
<body>
Free Study Material Buy Ty Diploma Buy Sy Diploma Whatsapp Group for Study Material
<option
value="https://www.google.com">Google</option>
<option
value="https://www.msbte.org.in">MSBTE</option>
<option
value="https://www.yahoo.com">Yahoo</option>
</form>
</body>
</html>
Q13.Write a java script that will replace following specified value with another value in string(use
replace method)
Q16. Write a JavaScript program that will display current date in DD/MM/YYYY format.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
Free Study Material Buy Ty Diploma Buy Sy Diploma Whatsapp Group for Study Material
<meta
name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<body>
<script>
var currentDate=d.getDate()+'/'+(d.getMonth()+1)+'/'+d.getFullYear()
document.write(currentDate)
</script>
</body>
</html>
Q17. Write HTML script that will display dropdown list containing options such as Red, Green, Blue
and Yellow. Write a JavaScript program such that when the user selects any options. It will change
the background colour of webpage.
Answer:
<html>
<body>
<option value="red">Red</option>
<option value="green">Green</option>
<option value="blue">Blue</option>
<option value="yellow">Yellow</option>
</select>
<script type="text/javascript">
function changeColor() {
switch(color){
case "green":
document.body.style.backgroundColor = "green";
Free Study Material Buy Ty Diploma Buy Sy Diploma Whatsapp Group for Study Material
break;
Free Study Material Buy Ty Diploma Buy Sy Diploma Whatsapp Group for Study Material
case "red":
document.body.style.backgroundColor = "red";
break;
case "blue":
document.body.style.backgroundColor = "blue";
break;
case "yellow":
document.body.style.backgroundColor = "yellow";
break;
default:
document.body.style.backgroundColor = "white";
break;
</script>
</body>
</html>
Answer:
<html >
<head>
<title>Banner Ads</title>
<script>
CurrentBanner = 0;
function DisplayBanners()
if (document.images);
Free Study Material Buy Ty Diploma Buy Sy Diploma Whatsapp Group for Study Material
CurrentBanner++;
if (CurrentBanner == Banners.length)
CurrentBanner = 0;
document.RotateBanner.src= Banners[CurrentBanner];
setTimeout("DisplayBanners()",1000);
</script>
</head>
<center>
</center>
</body>
</html>
The frequency or position of bracketed character sequences and single characters can be denoted by
a special character. Each special character has a specific connotation. The +, *, ?, and $ flags all
Free Study Material Buy Ty Diploma Buy Sy Diploma Whatsapp Group for Study Material
follow a character
sequence.
Example:
<html>
<body>
<p id="demo"></p>
<script>
function myFunction()
document.getElementById("demo").innerHTML = result;
</script>
</body>
</html>
Free Study Material Buy Ty Diploma Buy Sy Diploma Whatsapp Group for Study Material
Q20: Describe how to link
banner advertisement to URL with example.
The banner advertisement is the hallmark of every commercial web page. It is typically
positioned near the top of the web page, and its purpose is to get the visitor's attention by
To get additional information, the visitor is expected to click the banner so that a new web
page opens. You can link a banner advertisement to a web page by inserting a hyperlink
into your web page that calls a JavaScript function rather than the URL of a web page. The
JavaScript then determines the URL that is associated with the current banner and loads the
Example:
<html>
<head>
'google.com/','vpt.edu.in/', 'msbte.org.in/');
CurrentBanner = 0;
NumOfBanners = Banners.length;
function LinkBanner()
document.location.href =
"http://www." + BannerLink[CurrentBanner];
function DisplayBanners() {
if (document.images) {
CurrentBanner++
if (CurrentBanner == NumOfBanners) {
CurrentBanner = 0
document.RotateBanner.src= Banners[CurrentBanner]
Free Study Material Buy Ty Diploma Buy Sy Diploma Whatsapp Group for Study Material
setTimeout("DisplayBanners()",1000)
</script>
</head>
<center>
</center>
</body> </html>
Free Study Material Buy Ty Diploma Buy Sy Diploma Whatsapp Group for Study Material