Page 217 - Web Applications (803) Class 12
P. 217
</body>
</html>
Output of the preceding program is as follows:
Example 2: In this example, when the mouse cursor is brought over some text on the webpage, mouseover
event is triggered. This calls the function display() which shows a message in an alertbox.
<html>
<script>
function display()
{
alert("Hi! Interesting isn't it!");
}
</script>
<body>
<h2> Javascript Events </h2>
<font color="blue">
<p onmouseover="display()"> Keep the mouse cursor over me</p>
</font> </body> </html>
Output of the preceding program is as follows:
Example 3: In this example, when the user clicks inside the input box to enter text, the focus event is triggered
which calls the changecolour() function. Through the function, the background colour of the textbox changes
to aqua.
<html>
<script>
function changecolour()
{
document.getElementById("input1").style.background="aqua";
}
</script>
<body>
<h2> Enter text in the textbox and see the colour change!</h2>
Web Scripting—JavaScript 215

