CSS 4m ^0 6m answers(only code)
CSS 4m ^0 6m answers(only code)
questions:
3.
<script>
function openNewWindow() {
window.open("https://example.com", "_blank");
}
</script>
</body>
</html>
<script>
function redirectToWebsite(url) {
if (url !== "#") window.location.href = url;
}
</script>
</body>
</html>
Here are the remaining answers in the HTML + JavaScript format:11.
11)Describe Regular Expression Quantifiers
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-
scale=1.0">
<title>Regular Expression Quantifiers</title>
</head>
<body>
<script>
let text = "hello world";
let regex1 = /l{2}/; // Matches exactly 2 'l's
let regex2 = /o+/; // Matches one or more 'o's
let regex3 = /l*/; // Matches zero or more 'l's
document.write("<p>Regex1 (/l{2}/): " + regex1.test(text) +
"</p>");
document.write("<p>Regex2 (/o+/): " + regex2.test(text) + "</p>");
document.write("<p>Regex3 (/l*/): " + regex3.test(text) + "</p>");
</script>
</body>
</html>
<script>
let images = ["image1.jpg", "image2.jpg", "image3.jpg"];
let index = 0;
function rotateBanner() {
index = (index + 1) % images.length;
document.getElementById("banner").src = images[index];
}
<script>
function openNewWindow() {
window.open("https://www.example.com", "ExampleWindow",
"width=800,height=600");
}
</script>
</body>
</html>
<script>
let images = ["image1.jpg", "image2.jpg", "image3.jpg"];
let index = 0;
function showSlide() {
document.getElementById("slideshow").src = images[index];
}
function nextSlide() {
index = (index + 1) % images.length;
showSlide();
}
function prevSlide() {
index = (index - 1 + images.length) % images.length;
showSlide();
}
</script>
</body>
</html>
<script>
function writeCookie() {
document.cookie = "username=JohnDoe; expires=Fri, 31 Dec 2024
23:59:59 GMT";
alert("Cookie written!");
}
function readCookie() {
alert("Cookies: " + document.cookie);
}
</script>
</body>
</html>
<script>
function evaluateCheckbox() {
let selected = [];
if (document.getElementById("option1").checked)
selected.push("Option 1");
if (document.getElementById("option2").checked)
selected.push("Option 2");
alert("Selected options: " + selected.join(", "));
}
function evaluateRadio() {
let gender =
document.querySelector('input[name="gender"]:checked');
alert("Selected gender: " + (gender ? gender.value : "None"));
}
</script>
</body>
</html>
<script>
function focusEvent() {
alert("Input field is focused");
}
function blurEvent() {
alert("Input field is unfocused");
}
function formSubmitted(event) {
event.preventDefault(); // Prevent page reload
alert("Form submitted successfully!");
}
</script>
</body>
</html>
<h3>Browser History</h3>
<button onclick="goBack()">Go Back</button>
<button onclick="goForward()">Go Forward</button>
<script>
document.getElementById("location").innerText =
window.location.href;
function redirect() {
window.location.href = "https://www.google.com";
}
function goBack() {
window.history.back();
}
function goForward() {
window.history.forward();
}
</script>
</body>
</html>
<script>
function redirectToAd() {
window.open("https://www.example-ad.com", "_blank");
}
</script>
</body>
</html>
<label for="comments">Comments:</label>
<textarea id="comments" rows="4" cols="50"></textarea><br><br>
<label for="gender">Gender:</label>
<select id="gender">
<option value="male">Male</option>
<option value="female">Female</option>
</select><br><br>
<label>
<input type="checkbox"> Agree to Terms
</label><br><br>
<button type="submit">Submit</button>
</form>
</body>
</html>
<script>
document.getElementById("width").innerText = window.innerWidth;
document.getElementById("height").innerText = window.innerHeight;
document.getElementById("location").innerText =
window.location.href;
document.getElementById("navigator").innerText =
navigator.userAgent;
</script>
</body>
</html>
let count = 0;
function startCounter() {
setInterval(() => {
count++;
document.getElementById("counter").innerText = count;
}, 1000); // 1-second interval
}
</script>
</body>
</html>
<script>
function validateEmail() {
const email = document.getElementById("email").value;
const regex = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
document.getElementById("emailResult").innerText =
regex.test(email) ? "Valid Email" : "Invalid Email";
}
function validateAadhaar() {
const aadhaar = document.getElementById("aadhaar").value;
const regex = /^\d{4}-\d{4}-\d{4}$/;
document.getElementById("aadhaarResult").innerText =
regex.test(aadhaar) ? "Valid Aadhaar" : "Invalid Aadhaar";
}
function validatePhone() {
const phone = document.getElementById("phone").value;
const regex = /^\(\d{3}\)-\d{8}$/;
document.getElementById("phoneResult").innerText =
regex.test(phone) ? "Valid Phone Number" : "Invalid Phone Number";
}
</script>
</body>
</html>
If there are any other questions you’d like me to format or code out, let me know!