A 2
A 2
A 2
Write javascript
code such that when user clicks on start button real time digital clock will be displayed on
screen. When user clicks on stop button clock will stop displaying time.
<!DOCTYPE html>
<html>
<body>
<button onclick="c()">Start time interval</button>
<button onclick="d()">Stop time interval</button>
<h1 id="ht"></h1>
<script>
var tint;
function c() {
tint = setInterval(mySetInt, 1000);
}
function d() {
clearInterval(tint);
}
function mySetInt() {
const d = new Date();
document.getElementById("ht").innerHTML = d.toLocaleTimeString();
}
</script>
</body>
</html>
2. Frame 1 contains 3 buttons SPORT, MUSIc and DANC. When user clicks SPORT buttin
sport.html webpage will appear in Frame 2, When user click MUSIC button,music.html
webpage will appear in FRAME 3, When user5 clicks DANCE button, dance.html webpage will
appear in FRAME 4
Frame 1
SPORT MUSIC DANCE
FRAME 2 FRAME 3 FRAME 4
<html>
<frameset rows="20%,*">
<frame src="frame1.html" name="frame1" />
<frameset cols="*,*,*">
<frame src="frame2.html" name="frame2" />
<frame src="frame3.html" name="frame3" />
<frame src="frame2.html" name="frame2" />
</frameset>
</frameset>
</html>
5. Write a javascript function that will open new window when user will click on button
<!DOCTYPE html>
<html>
<body>
<h2>The open() Method</h2>
<button onclick="myFunction()">Open it</button>
<script>
function myFunction() {
myWindow = window.open("", "", "width=200,height=100");
}
</script>
</body>
</html>
Quantifier Description
n+ Matches any string that contains at least one n
n* Matches any string that contains zero or more occurrences of n
n? Matches any string that contains zero or one occurrences of n
n{X} Matches any string that contains a sequence of X n's
n{X,Y} Matches any string that contains a sequence of X to Y n's
n{X,} Matches any string that contains a sequence of at least X n's
n$ Matches any string with n at the end of it
^n Matches any string with n at the beginning of it
?=n Matches any string that is followed by a specific string n
?!n Matches any string that is not followed by a specific string n
<!DOCTYPE html>
<html>
<body>
<script>
let result = "World".match(/r+/g);
alert(result);
result = "Hellooo".match(/r+/g);
alert(result);
</script>
</body>
</html>
9. Write a webpage that displays a form that contains an input for username and password. User
is prompted to entire the input and password and password becomes the value of cookie.
Write a javascript function for storing the cookie. It gets executed when the password
changes.
<html>
<head>
<script>
function storeCookie()
{
var pwd = document.getElementById('pwd').value
document.cookie = "Password=" + pwd + ";"
alert("Cookie Stored\n" + document.cookie)
}
</script>
</head>
<body>
<form name="myForm">
Enter Username <input type="text" id="uname"/><br/>
Enter Password <input type="password" id="pwd"/><br/>
<input type="button" value="Submit" onclick="storeCookie()"/>
<p id="panel"></p>
</form>
</body>
</html>
11. Explain open() method of window object with syntax and example.
open()
It opens a new browser window, or a new tab, depending on your browser settings and the
parameter values.
Syntax:
window.open(URL, name, specs, replace)
URL
It is Optional.
The URL of the page to open.
If no URL is specified, a new blank window/tab is opened
name
It is Optional.
The target attribute or the name of the window.
The following values are supported:
<!DOCTYPE html>
<html>
<body>
<h2>The open() Method</h2>
<button onclick="myFunction()">Open it</button>
<script>
function myFunction() {
window.open("https://www.google.com");
}
</script>
</body>
</html>
12. Write a javascript to modify the status bar using on Mouseover and on mouseout with links.
When the user moves his mouse over the link, it will displa “MSBTE” in status bar.When user
moves his mouse away from the link the status bar will display nothing.
<!DOCTYPE html>
<html>
<body>
<a href="www.msbte.org.in" id="demo" name="demo" onmouseover="ov()"
onmouseout="out()"> LINK MSBTE</a>
<script>
let deomImage = document.getElementById("demo");
deomImage.addEventListener("mouseover", function () {
window.status = "MSBTE";
});
deomImage.addEventListener("mouseout", function () {
window.status = "";
});
</script>
</body>
</html>