Change Background Colors

Submitted by:Andery Smith

Date added:13 November, 2012

Category:JavaScript

Use this snippet to let your visitors change the background color of your Web page. Combined with a cookie, the setting could follow them through your whole site.

Tags: background colors

Code Snippet:

# Paste this code into the HEAD section of your HTML document.


function bgChange() {
document.bgColor=document.getElementById("f").txt.value;
}


===============

# Paste this code into the BODY section of your HTML document


<form id="f">
Enter new background color: <input type="text" name="txt">
<input type="submit" value="Change color" onclick="bgChange(); return false;">
</form>
 
 

Comments