Hi,

When i'm click on the web page, the page turn off to balck color. is it possible?
Help me..........

<html>
<body onMouseover="document.bgcolor='black'">
<font>
.
.
.
</font>
</body>
</html>

It was working fine for me.

commented: You solved my problem. Thanks., +0

Thank you. It was also working fine to me.

If you are creating a page and want to change the background on click you might just assign a click event to the window that would toggle the background color of the page.For example:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
        "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

<html>
<head>
<style type=text/css>
html,body{
	height:100%;
	width:100%;
}
</style>
<!--<script src="../lib/jquery-1.3.2.js" type="text/javascript"></script>-->
<script type="text/javascript">
 function init(){
	document.body.onclick = function(){
		colorChange();
	}		
	function colorChange(){
		var colors = ["red","green","blue","orange","pink"];
		var index = Math.floor(Math.random() * 100) % 5;
		document.body.style.background = colors[index];
	}
}
window.onload = init;
</script>
</head>
<body>
<p>Click the page to change colors</p>
</body>
</html>

In IE it is important to set the height and width of the body and html to 100% or IE thinks the body is just around the content and not the size of the screen. In FF it doesn't matter.

Ur code was ok. But the poster was asking not to create a page. Just apply color when click on the page. As per his post, i suggest this code.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.