[go: up one dir, main page]

0% found this document useful (0 votes)
28 views12 pages

CSS QB Ans

Uploaded by

Gaurang Rane
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
28 views12 pages

CSS QB Ans

Uploaded by

Gaurang Rane
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 12

CSS QB ANS

1. Define cookie and explain how to create a cookie with example

A cookie is a small piece of data stored by the web browser on the user's computer. It is used
to remember information about the user between visits or during a single session on a
website. Cookies are commonly used for purposes like session management, personalization,
and tracking user behavior.

2. Explain the term timer in detail

3. Explain how to create a web page and how to open a web page in new window
4. Write a JavaScript code to implement scroll by
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Scroll By Example</title>
</head>
<body>
<button onclick="scrollPage()">Scroll Down</button>

<script>
function scrollPage() {
// Scrolls the page down by 100px vertically
window.scrollBy(0, 100);
}
</script>
</body>
</html>

5. Explain regular expression with example

6. How to create a rollover explain in detail


7. Writer JavaScript to replace text using regular expression and matching term

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Replace Text Example</title>
</head>
<body>

<p id="text">I like apple pie, apple juice, and apple tart.</p>
<button onclick="replaceText()">Replace "apple" with "orange"</button>

<script type="text/javascript">
function replaceText() {
var text = document.getElementById('text').innerHTML;

var regex = /apple/g;


var replacedText = text.replace(regex, "orange");

document.getElementById('text').innerHTML = replacedText;
}
</script>

</body>
</html>
8. Define banner and status bar
 Banner: A banner is a prominent section, usually at the top of a webpage, used to display key
messages, advertisements, or announcements. It grabs users' attention and often contains
information like promotions, updates, or site navigation links.

 Status Bar: A status bar is a small, usually horizontal bar at the bottom of the screen or
window. It provides real-time information about the application's state, such as page loading
progress, system notifications, or connection status.

9. Explain how to hide code in JavaScript

In JavaScript, you can hide code by using **comments**. Comments are not executed by the
browser, allowing developers to add explanations or temporarily disable sections of code without
removing them.

There are two types of comments:

1. Single-line comments: These are used to comment out a single line of code. They start with `//`,
and everything following it on that line is ignored by the browser.

2. Multi-line comments: These allow you to comment out multiple lines of code. They are enclosed
between `/*` and `*/`, and anything between these symbols is ignored.

By using comments, developers can hide code for debugging, documentation, or temporarily
disabling parts of the code without affecting the program's execution.

10. Compare pop up menu and contest menu

Pop-up menu Contest menu

A menu that appears over the page when A menu that appears when the user right-clicks
triggered by an event, like clicking a button or a on an element, offering context-specific
link. options.

Can be triggered by various events, such as Triggered by right-clicking (or long-tapping on


clicking a button or a specific area on the page. mobile) on a specific item or area on the
screen.

Used for general actions like navigation, tool Provides options specific to the element or
selection, or app-specific functions. context clicked (e.g., copying text, opening
links).

Visible when triggered by a specific event, such Appears when the user right-clicks an element
as clicking a button or menu item. and is usually related to the content clicked.
A button that opens a menu with different Right-clicking on a text field to see options like
navigation options. "Copy," "Paste," and "Select All."

11. Write a JavaScript to implement pull down menu and folding tree menu
Pulldown menu:

Folding Tree menu:

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Folding Tree Menu</title>
<style>
ul {
list-style-type: none;
padding-left: 20px;
}

li {
cursor: pointer;
}

.nested {
display: none;
}

li.active > .nested {


display: block;
}
</style>
</head>
<body>

<ul>
<li onclick="toggleMenu(event)">Item 1
<ul class="nested">
<li>Sub-item 1</li>
<li>Sub-item 2</li>
</ul>
</li>
</ul>

<script>
function toggleMenu(event) {
var li = event.target;
li.classList.toggle("active");
}
</script>

</body>
</html>

12. Write a JavaScript to create a new window and giving a focus to new window

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>New Window Example</title>
</head>
<body>

<button onclick="openNewWindow()">Open New Window</button>

<script>
function openNewWindow() {
var newWindow = window.open("", "", "width=400,height=300");
newWindow.focus();
}
</script>

</body>
</html>

13. Explain JavaScript security in detail

1. Avoid `eval()`: `eval()` executes strings as code, which can be exploited by attackers. Use safer
alternatives to execute dynamic code.

2. Sanitize Input: Always clean user input to remove any potentially harmful characters. This
prevents attackers from injecting malicious code.

3. Use HTTPS: HTTPS encrypts communication between the server and browser, protecting sensitive
information. Always ensure your site uses `https://`.

4. Limit Sensitive Data: Keep sensitive data on the server, not in local storage or cookies. If you use
cookies, make them `HttpOnly` for added security.

5. Avoid Inline JavaScript: Inline JavaScript is vulnerable to attacks and harder to maintain. Use
external scripts and event listeners for cleaner, safer code.

14. Explain browser location and history

Browser Location:

The browser location refers to the URL of the current webpage that is displayed in the browser's
address bar. It can be accessed and manipulated using JavaScript through the `window.location`
object. This allows you to retrieve or modify the URL, reload the page, or redirect the user to a
different page.

Browser History:

The browser history refers to the list of previously visited pages within the current browser session.
It can be accessed through the `window.history` object, which provides methods for navigating
through the history, such as going back to the previous page or moving forward to the next one. It
enables custom navigation behavior, such as implementing back and forward buttons within a web
application.

15. Implement of following functions according to regular expression: a) test


b) match

16. Write a JavaScript to find out matching word: a) digit, non-digit

b) match character match non character

17. Explain frame and detail and write a script to create a frame

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Frames Example</title>
</head>
<body>

<frameset rows="50%,50%">
<frame src="https://www.example.com" name="frame1">
<frame src="https://www.wikipedia.org" name="frame2">
</frameset>

</body>
</html>

18. Implement text through rollover


19. Explain how to protect webpage and framework of Java and it's application
Protecting a webpage:

1. Use HTTPS:

- Encrypts data between the user's browser and the server, making it harder for attackers to
intercept information.

2. Validate User Input:

- Ensures that only safe and expected data is entered, preventing harmful scripts or malicious data
from affecting the website.

3. Session Management:

- Secures user sessions by using secure cookies and ensuring sessions expire after a set time to
prevent unauthorized access.

4. Password Security:

- Stores passwords in a secure way using encryption, preventing them from being compromised
even if the data is stolen.

Java Application Security:

1. Spring Security:

- Provides built-in features for authentication, authorization, and protection against common
attacks like CSRF and session hijacking.

2. Follow OWASP Best Practices:

- Ensures secure coding practices, like safe libraries and encrypted sensitive data, to avoid
vulnerabilities.

3. Database Security:

- Protects against SQL injection by using parameterized queries and ensures database credentials
are stored securely.

4. Logging and Monitoring:

- Regularly checks logs for unusual activities and monitors the application for potential security
threats to respond quickly.

20. Write a script to implement banner, slideshow, pulldown menu, dynamically changing menu,
validating menu selection, floating menu, tab menu, popup menu
1. Banner:

<div id="banner" style="background-color: lightblue; padding: 10px; text-align: center;">


<h2>Welcome to Our Website</h2>
</div>

2. Slideshow:

<div id="slideshow">
<img id="slide" src="https://via.placeholder.com/600x300?text=Slide+1" style="width:100%;">
</div>
<script>
let slides = [
"https://via.placeholder.com/600x300?text=Slide+1",
"https://via.placeholder.com/600x300?text=Slide+2",
"https://via.placeholder.com/600x300?text=Slide+3"
];
let currentSlide = 0;

function showSlide() {
document.getElementById('slide').src = slides[currentSlide];
currentSlide = (currentSlide + 1) % slides.length;
}

setInterval(showSlide, 3000); // Change slide every 3 seconds


</script>

3. Pulldown menu

<select>
<option>Select an option</option>
<option>Option 1</option>
<option>Option 2</option>
<option>Option 3</option>
</select>

You might also like