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 (20)
- changing bgcolor javascript using alert (15)
- how to change background color using javascript (14)
- Changing the Background Color of a Page using jQuery (12)
- change bgcolor using javascript (12)
- change web page background color (8)
- background color using javascript (7)
- change browser color javascript (7)
- jquery change body background color (7)
- how to change the background color using javascript (7)
- how to change web page background color using javascript (6)
- changing background color using javascript (6)
- change body background color using javascript (6)
- change web page background color javascript (5)
- color using javascript (5)
- how to change background color in javascript with one button (4)
- change background color with one button javascript (4)
- changing color using javascript (4)
- how to add background color in javascript using button (3)
- to include background color in web page in javascript (3)
- body background color change using javascript (3)
- change background colour of one page with java (3)
- change background color using javascript function (3)
- change backround of a website using javascribt (3)
- how to change java script on website (3)
- change background using javascript (3)
- hot to change website color with js (3)
- change color using javascript (3)
- how to change background of webpage using javascript (3)
- javascript timer change background color (3)
- javascript change website color (3)
- change website using javascript (3)
- background color dynamically change using java script (3)
- change background color using button in javascript (3)
- php javascript background color to choose of at website (2)
- full website color change javascript (2)
- jquery change body bgcolor (2)
- javascript change website (2)
- jquery change body background (2)
You will also be interested in ,
- Character Encoder And Decoder Using Javascript
- Random images per day using javascript and jquery
- Javascript Countdown Script
- Banner rotator with preference using javascript
- Dynamically Changing hyperlink color on a website using javascript
- A single link that cycles through several webpage background color using javascript
- HTTP referrer using javascript
- Displaying Text from User On Your Webpage
- Change webpage font color or background color from the user side using javascript
- Visitor counter using cookies and 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”
Thank you for this tutorial.
How would this be done by having only one link that cycles through several background colours?
Thanks!
Takashi
Just check our new tutorial
http://mistonline.in/wp/a-single-link-that-cycles-through-several-webpage-background-color-using-javascript/
I think it will solve your concern.
i have done web development long ago, but now have a friend who is color blind, and i am wondering if there is any way to change colors/text from the user side
thankx
Hello Frank,
If that is the case check our New Tutorial Here, It will ask the users which color they need on the website. This should help