坐月子能吃通草下奶吗:谁帮我做个简单的网页,超级简单的

来源:百度文库 编辑:高校问答 时间:2024/04/29 10:42:05
就是做一个每刷新一次,网页背景就随机改变一次的效果.谢谢啦
只要改变背景颜色就行(背景颜色是随机的,所有颜色都要,从#000000~#FFFFFF),不要用图片

这个要空间干吗?直接贴代码上来就行了,

3楼的不行,颜色是要随机产生的,而且也不是定时改颜色,而是刷新后改颜色

5楼的代码我运行后没反应哩,是不是要写<body onload="chgColor"></body>我写了没反应啊.

我已经把写好的页面发你了:)

//将rgb从十进制转换到十六进制(#xxxxxx形式)
function RGB_HEX(r,g,b)
{
return "#" +toHex( r) + toHex(g) + toHex(b);
}

function toHex(d)
{
if(isNaN(d)) d=0;
else if(d<0) d=0;
else if(d>255) d=255;

var n=parseInt(d).toString(16);
return n.length==1?"0"+n:n;
}

//产生从low到high随机数(包含边界)
function randomValue(low, high)
{
var n;
n=Math.floor(Math.random() * (high-low+1) + low);
return n;
}

function chgColor()
{
var r,g,b;
r=randomValue(0,255);
g=randomValue(0,255);
b=randomValue(0,255);
document.body.style.backgroundColor=RGB_HEX(r,g,b);
}

//---还看不懂就没办法了

这个应该比较简单了

<script:language="javascript">
function change(obj){
r=randomValue(0,255);
g=randomValue(0,255);
b=randomValue(0,255);
obj.bgcolor=RGB_HEX(r,g,b);
}
</script>
<body onLoad="change(this)">
</body

很简单啊<script:language="javascript">
function change(obj){
r=randomValue(0,255);
g=randomValue(0,255);
b=randomValue(0,255);
obj.bgcolor=RGB_HEX(r,g,b);
}
</script>
<body onLoad="change(this)">
</body

楼上的才是高手啊

楼上的都是高手