Hello guys, i am back again with yet another simple but interesting tutorial of changing webpage background color using javascript, just copy and paste it to your webpage and customize it according to your webpage design.
<script language="javascript">
function chngebg (id)
{
switch (id)
{
case 'b1':
document.body.bgColor = "red";
break;
case 'b2':
document.body.bgColor = "blue";
break;
case 'b3':
document.body.bgColor = "black";
break;
case 'b4':
document.body.bgColor = "yellow";
break;
}
}
</script>
<body>
<input type="button" id="b1" onclick="chngebg(this.id)" value="Red"/>
<input type="button" id="b2" onclick="chngebg(this.id)" value="Blue"/>
<input type="button" id="b3" onclick="chngebg(this.id)" value="Black"/>
<input type="button" id="b4" onclick="chngebg(this.id)" value="Yellow"/>
</body>
Incoming search terms:
- use jquery to change document background color dynamically (36)
- Change background color using JavaScript (16)
- changing bgcolor javascript using alert (15)
- Changing the Background Color of a Page using jQuery (11)
- change bgcolor using javascript (10)
- how to change background color using javascript (9)
- change web page background color (8)
- jquery change body background color (7)
- background color using javascript (7)
- change browser color javascript (7)
- how to change web page background color using javascript (6)
- changing background color using javascript (6)
- color using javascript (5)
- how to change the background color using javascript (5)
- change background color with one button javascript (4)
- change body background color using javascript (4)
- change web page background color javascript (4)
- change background color of site jquery keypress (3)
- change color using javascript (3)
- how to change java script on website (3)
- change background colour of one page with java (3)
- change background color using button in javascript (3)
- how to add background color in javascript using button (3)
- change background using javascript (3)
- to include background color in web page in javascript (3)
- how to change background color in javascript with one button (3)
- hot to change website color with js (3)
- change backround of a website using javascribt (3)
- how to display color in buttons using jsp (3)
- javascript change website color (3)
- change website background color (3)
- background color dynamically change using java script (3)
- javascript timer change background color (3)
- change website using javascript (3)
- how to change background of webpage using javascript (3)
- javascript change website (2)
- jquery change body bgcolor (2)
- change web page background using javascript (2)
- full website color change javascript (2)
- change web page javascript (2)
You will also be interested in ,
- Removing Nodes using javascript
- Replace all non alphanumeric characters using javascript
- Passing variables from javascript to php
- LED Display or Scrolling text using javascript
- Alert a message before leaving a web page using javascript
- Suppress javascript errors on your webpage easily
- Replacing images with time intervals using jquery
- Agree Before Entry Using Javascript
- Javascript Popup Chromeless Window
- New Year and Christmas count down script using javascript

Hi, my friend showed me that you can use javascript to change things in your browser by doing stuff like javascript:”Hi” and that, but I forgot how to change the background color, not of your website, but turn your browser window into a solid color. Help, please?
You cannot change your browser color as far as i know, you can just change your web-page background.
I tried to copy this code in, but it didnt work. Thought it might have been due to css attachment so got rid of that but still not working, any suggestions?
Hello Alan,
Thanks for your comment, Please check now, I have made the code much easier for copy paste.[Previously some extra character was popping up while copying and that might prevented the code from working, fixed it]
Please let me know if you have any issues.
Nice information. I like it. Thank
Hello, I find your article useful… However I also need to change the font color along with the background color & also I wonder if you can change the bg color for other div within the same page as well… Is there a way to do that? Thanks.
Hello,
Thanks for your comment.
Yes you can do that by using this attribute document.getElementById(‘YOUR DIV NAME’).style.backgroundColor = “YOUR COLOR”