You are on page 1of 7

ASSIGNMENT-7

• If mouse button is pressed background is red and if mouse button is


released background is yellow.

<html>
<head>
<script>
function Mousedown()
{
document.body.style.background = "red";
}
function Mouseup()
{

document.body.style.background = "yellow";
}
</script>
</head>
<body>
<p onmousedown="Mousedown()" onmouseup="Mouseup()">chandni</p>
</body>
</html>

OUTPUT:
2.write a javascript 1) which mousebutton was click
2)no of form document.

<html>
<head>
<script>
function WhichButton(event)
{
Alert ("you pressed button:"+ event.button);
}
function Count()
{
alert (form1.length);
}
</script>
</head>
<body >
<form name="form1">
<div onmousedown="WhichButton(event)">
Jinal
</div>
<input type="text" name="nm" />
<input type="text" name="nm2" />
<input type="text" name="n1mm" />
<button onclick="Count()" value="count">Count</button>
</form>
</body>
</html>
OUTPUT:

3. write a java script for below events.

<html>
<head>
<script>
function Mouse()
{
document.getElementById("h").style.color="yellow";
}
function mouse2()
{
document.getElementById("h").style.color="black";
}
function time()
{
t=new Date();
alert(t.toString());
}
function red ()
{
document.body.style.background="red";
}
function green()
{
document.body.style.background="green";
}
function unload()
{
alert("bye-bye");
}
</script>
</head>
<body onunload="unload()">
<h1 id="h" onmouseover="Mouse()"
onmouseout="mouse2()">chandni</h1>
<button onclick="time()">Find Time</button>
<button onclick="red()">Red</button>
<button onclick="green()">Green</button>

</body>
</html>

OUTPUT:
4.write a java script for below events.

<html>
<head>
<script>
function Code(event)
{
var x = event.keyCode ;
document.write (x.toString());

}
function Vowels(event)
{
var y1 = event.keyCode;
document.write(y1.toString());
if (y1 == '97' || y1 == '101' || y1 == '105' || y1 == '111' || y1 ==
'117')
{
alert("vowels");
}
}
function bg()
{
document.body.style.background="blue";
}
</script>
</head>
<body>
keycode <input type="text" onkeypress="Code(event)" ></input><br/>
vowels <input type="text" onkeypress="Vowels(event)" ></input><br/>
background color <input type="text" onkeyup="bg()"></input>

</body>
</html>

OUTPUT:

You might also like