jsfunction setRadBg()
{
bg = new Array(4); //设定图片数量,如果图片数为3,这个参数就设为2,依次类推
bg[0] = '1.gif' //显示的图片路径,可用http://
bg[1] = '2.gif'
bg[2] = '3.gif'
bg[3] = '4.gif'
bg[4] = '5.gif'
index = Math.floor(Math.random() * bg.length);
document.body.style.background = bg[index];
}<body onload="setRadBg;">改成这样试试
未经测试
{
bg = new Array(4); //设定图片数量,如果图片数为3,这个参数就设为2,依次类推
bg[0] = '1.gif' //显示的图片路径,可用http://
bg[1] = '2.gif'
bg[2] = '3.gif'
bg[3] = '4.gif'
bg[4] = '5.gif'
index = Math.floor(Math.random() * bg.length);
document.body.style.background = bg[index];
}<body onload="setRadBg;">改成这样试试
未经测试
<body onload="setRadBg();">
function set_bg(){
bg = new Array(4); //设定图片数量,如果图片数为3,这个参数就设为2,依次类推
bg[0] = '1.gif' //显示的图片路径,可用http://
bg[1] = '2.gif'
bg[2] = '3.gif'
bg[3] = '4.gif'
index = Math.floor(Math.random() * bg.length);
return bg[index];
}
web页面:
<html>
<head>
</head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>无标题文档</title>
</head>
<body onload='this.background=set_bg();'>
</body>
</html>
<head><script LANGUAGE="JavaScript">
bg = new Array(4); //设定图片数量,如果图片数为3,这个参数就设为2,依次类推
bg[0] = '1.gif' //显示的图片路径,可用http://
bg[1] = '2.gif'
bg[2] = '3.gif'
bg[3] = '4.gif'
bg[4] = '5.gif'
index = Math.floor(Math.random() * bg.length);
document.body.background="+bg[index];
</script><meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>无标题文档</title>
</head><body></body>
</html>
这个地址里面该怎么写 我要调用的是上面的5个图片 ,高手指点 谢谢
function set_bg(){
bg = new Array(4); //设定图片数量,如果图片数为3,这个参数就设为2,依次类推
bg[0] = '1.gif' //显示的图片路径,可用http://
bg[1] = '2.gif'
bg[2] = '3.gif'
bg[3] = '4.gif'
index = Math.floor(Math.random() * bg.length);
return bg[index];
}
</script><img src="set_bg();">
这样的?
{
bg = new Array(4); //设定图片数量,如果图片数为3,这个参数就设为2,依次类推
bg[0] = '1.gif' //显示的图片路径,可用http://
bg[1] = '2.gif'
bg[2] = '3.gif'
bg[3] = '4.gif'
bg[4] = '5.gif'
index = Math.floor(Math.random() * bg.length);
document.body.style.background = bg[index];
}<body onload="setRadBg;">body onload='this.background=bg();'>