I really got carried away with this version:
Code:
<form action="javascript:void(0);"
onsubmit="this.go.onclick.apply(this.go);return false;">
<div>Type in Color: <input type="text"
onchange="window.colorswap=0; window.color_saved =
document.body.style.backgroundColor? document.body.style.backgroundColor : 'white';">
<input name="go" type="button"
onclick="this.form.current.value = document.body.style.backgroundColor =
(window.colorswap=!window.colorswap)? this.form[0].value :
window.color_saved? window.color_saved : 'white';
if(window.colorswap&&document.body.style.backgroundColor!=this.form[0].value){
var got=0;
if(!window.color_table)
window.color_table=[];
for (var i = 0; i < window.color_table.length; i++)
if(window.color_table[i][0]==document.body.style.backgroundColor)
got=1;
if(!got)
window.color_table[window.color_table.length] =
[document.body.style.backgroundColor, this.form[0].value];
}
if(window.color_table&&/^#|(rgb)/.test(this.form.current.value.replace(/ /g,'')))
for (var i = 0; i < window.color_table.length; i++)
if(window.color_table[i][0]==document.body.style.backgroundColor)
this.form.current.value=window.color_table[i][1];"
value="Swap"><br>
Current Color: <input type="text" name="current" readonly value="white">
</div>
</form>
Bookmarks