如何让用户能够自定义他们自己的区域——颜色或墙纸

How to allow users the ability to customise their own area - colours or wallpaper

我需要有关网站某些元素的帮助,以使登录用户能够更改其登录区域的颜色或背景。我正在寻找快速完成此任务的最佳方法。

我想要类似这样的东西:

onclick="document.getElementById('id1').style.color = 'red'"> 点击我!

虽然它需要是永久的并且在重新登录后仍然存在。

这是我用 js 做的一个简单的解决方案fiddle。 http://jsfiddle.net/tycyy15L/5/

 window.onload = function() {


var boxlength = document.getElementsByClassName("coloredBox").length;


for(i = 0; i < boxlength; i++){
document.getElementsByClassName("coloredBox")[i].onclick = function(){
document.body.style.backgroundColor = this.style.backgroundColor;
            }
    }

}

(其余请参见 js fiddle)和 cookie 版本。

如果需要永久保存,您很可能需要使用数据库。如果它是半永久性的,您可以像我的 fiddle 一样使用 cookie。