changing the background color of the page - (document.bgcolor) - HTML Views : 375
Tagged in : HTML
Send mail vote down 0 vote down 0
The easiest way to change the background color of a page is using the property bgcolor.

document.bgColor="green";

Example: Code
<script language=javascript>
document.write("<input type=button value=red onclick=bgc()>");
function bgc(){
alert("sdsd");
document.bgColor="#e1FFE1";
}
</script>



But note that you have to set the color to the proper element. If there are elements like table which are above the document with color set on it, this wont work.

Then you will have to use something like

document.getElementById('<element id>').bgColor="green";


By - Sanju, On - 2010-02-05




    Login to add Comments .