0% found this document useful (0 votes)
9 views

css 2 marks q

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

css 2 marks q

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

CSS QB BY PRATH

a) Enlist & explain the use of any two Intrinsic JavaScript functions.

1. parseInt() Function:

 Purpose: Converts a string into an integer.


 Syntax: parseInt(string, radix)
o string: The input value to be parsed.
o radix: Optional. Specifies the base of the numeral system (e.g., 10 for
decimal, 2 for binary).
 Example:

javascript
Copy code
console.log(parseInt("123")); // Output: 123
console.log(parseInt("1010", 2)); // Output: 10 (binary to decimal)

2. setTimeout() Function:

 Purpose: Executes a function after a specified delay (in milliseconds).


 Syntax: setTimeout(function, delay)
o function: The function to be executed.
o delay: Time in milliseconds to wait before executing.
 Example:

javascript
Copy code
setTimeout(() => {
console.log("Hello after 2 seconds");
}, 2000);

b) Describe the browser location object.

The location object in JavaScript contains information about the current URL and provides
methods to manipulate it. It is part of the window object and can be used to get or set the URL
of the browser.

 Properties:
o location.href: Full URL of the current page.
o location.protocol: Protocol used (e.g., http: or https:).
o location.hostname: Domain name (e.g., www.example.com).
o location.pathname: Path after the domain (e.g., /about).
o location.port: Port number (e.g., 8080).
o location.search: Query string (e.g., ?id=123).
 Methods:
o location.assign(url): Loads a new document.
o location.reload(): Reloads the current page.
o location.replace(url): Replaces the current document without saving it in
the session history.
CSS QB BY PRATH

c) Write attributes of location object.

1. href: The full URL of the current page.


2. protocol: The protocol used by the URL (e.g., http:, https:).
3. hostname: The domain name of the web host.
4. pathname: The path of the current page.
5. port: The port number (e.g., 80, 443).
6. search: The query string part of the URL (e.g., ?name=test).
7. hash: The anchor part of a URL (e.g., #section1).

d) Write attribute and functions of history object.

The history object allows you to manipulate the browser's history.

 Attributes:
o history.length: Number of URLs in the history stack.
 Functions:
o history.back(): Loads the previous URL in the history list.
o history.forward(): Loads the next URL in the history list.
o history.go(n): Loads a specific URL in the history list (n can be positive or
negative).

e) Write the use of innerHTML function along with syntax.

 Purpose: The innerHTML property is used to get or set the HTML content of an
element.
 Syntax:

javascript
Copy code
element.innerHTML = "New content";

 Example:

html
Copy code
<div id="demo">Original Content</div>
<script>
document.getElementById("demo").innerHTML = "Updated Content";
</script>
CSS QB BY PRATH

f) Write the meaning of symbols *, +, and ? with respect to Quantifiers with


suitable examples.

1. * (Asterisk): Matches 0 or more occurrences.


o Example: /a*/ matches a, aa, or an empty string.
2. + (Plus): Matches 1 or more occurrences.
o Example: /a+/ matches a, aa but not an empty string.
3. ? (Question mark): Matches 0 or 1 occurrence (optional).
o Example: /a?/ matches a or an empty string.

g) List and write the meaning of any 4 RegExp flags.

1. i: Case-insensitive match.
2. g: Global match (find all matches).
3. m: Multiline match.
4. s: Allows . to match newline characters.

h) List and define types of cookies.

1. Session cookies: Temporary cookies that are deleted when the browser is closed.
2. Persistent cookies: Stored on the user's device until they expire or are deleted
manually.
3. Secure cookies: Sent only over secure HTTPS connections.
4. HttpOnly cookies: Not accessible via JavaScript; helps prevent XSS attacks.

i) Write syntax to open a new window and explain the attributes.

 Syntax:

javascript
Copy code
window.open("https://example.com", "windowName",
"width=500,height=400");

 Attributes:
o URL: The URL to be opened.
o windowName: Name of the new window.
o width and height: Dimensions of the new window.
CSS QB BY PRATH

j) Write the difference between scrollTo() and scrollBy() functions.

1. scrollTo(x, y): Scrolls the page to a specific coordinate.


o Example: window.scrollTo(0, 500);
2. scrollBy(x, y): Scrolls the page by a relative amount.
o Example: window.scrollBy(0, 100);

k) Write a JavaScript program to display "Hello World" message in the


status bar.
javascript
Copy code
window.status = "Hello World";

Note: Modern browsers may not support this due to security concerns.

l) Write a JavaScript to design a form to accept values for user ID &


password.
html
Copy code
<form>
<label for="userID">User ID:</label>
<input type="text" id="userID" name="userID"><br><br>

<label for="password">Password:</label>
<input type="password" id="password" name="password"><br><br>

<button type="submit">Submit</button>
</form>

You might also like