How to Change Background Color of Document using JavaScript onmouseover ?

<html>
<head>
<script type="text/javascript">
<!--
function changeBGC(color){
document.bgColor = color;
}
//-->
</script>
</head>
<body>
<a href="#" onmouseover="changeBGC('#FF0000')">Background: Red</a><br />
<a href="#" onmouseover="changeBGC('#00FF00')">Background: Green</a><br />
<a href="#" onmouseover="changeBGC('#0000FF')">Background: Blue</a>
</body>
</html>

Explanation :

function changeBGC(color)
{
document.bgColor = color;
}
[arrowlist]
  • Function changeBGC() will change background color of the page.
  • This function is triggered by moving mouse pointer on link.
  • When we move cursor on the link onmouseover event is triggered and function is called.
[/arrowlist] Syntax of Calling JS Function :

<a href="#" onmouseover="changeBGC('#FF0000')">Background: Red</a>