css 2 marks q
css 2 marks q
a) Enlist & explain the use of any two Intrinsic JavaScript functions.
1. parseInt() Function:
javascript
Copy code
console.log(parseInt("123")); // Output: 123
console.log(parseInt("1010", 2)); // Output: 10 (binary to decimal)
2. setTimeout() Function:
javascript
Copy code
setTimeout(() => {
console.log("Hello after 2 seconds");
}, 2000);
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
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).
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
1. i: Case-insensitive match.
2. g: Global match (find all matches).
3. m: Multiline match.
4. s: Allows . to match newline characters.
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.
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
Note: Modern browsers may not support this due to security concerns.
<label for="password">Password:</label>
<input type="password" id="password" name="password"><br><br>
<button type="submit">Submit</button>
</form>