dingding今天问起我as是否可以改变网页的背景色
我想只有借助js的力量了,当然不想去用后台-w-
我对js不是很了解,查了下,发现改背景色是用document.bgColor=#XXXXXX,然后我就试着写了点,如下(场景500*400)
当然这些代码也只能在ie里面测试过,其它的浏览器,老实说,我都不怎么熟悉^^"
function drawRect(mc, color) {
mc.beginFill(color);
mc.lineStyle(0, color);
mc.moveTo(0, 0);
mc.lineTo(50, 0);
mc.lineTo(50, 50);
mc.lineTo(0, 50);
mc.lineTo(0, 0);
}
function resetBgColor() {
getURL("javascript:function bgc(c){document.bgColor=c;};bgc("+this.color+");");
}
function drawColorMixer() {
var i = 0;
for (var y = 0; y<400; y += 50) {
for (var x = 0; x<500; x += 50) {
var cm = this.createEmptyMovieClip("mc"+i, i);
cm._x = x;
cm._y = y;
cm.color = random(Number(0xffffff));
cm.onPress = resetBgColor;
drawRect(cm, cm.color);
i++;
}
}
}
drawColorMixer();