Saturday 17 January 2015

Simple javascript program


   

Q. When you click the button "OK", it will display a message "Welcome to Javascript" and when you click other buttons,the background will be in that colour.

<html>
<head>
<script>
function f1()
{
alert("Welcome to Javascript")
}
function f2()
{
document.bgColor="red"
}
function f3()
{
document.bgColor="blue"
}
function f4()
{
document.bgColor="green"
}
</script>
</head>
<body><br><br><br><center>
<input type=button value=OK onClick="f1()"><br><br><br>
<input type=button value=Red onClick="f2()">&nbsp&nbsp&nbsp&nbsp
<input type=button value=Blue onClick="f3()">&nbsp&nbsp&nbsp&nbsp
<input type=button value=Green onClick="f4()"></center><br>
</body>
</html>


No comments:

Post a Comment