随机显示图片的代码~

[不指定 2004/11/04 21:01 | by Totti ]
| |

随机改变显示图片,将下列代码加入BODY之间的适当位置
<script language="JavaScript">
<!--

a = 4 // a=numbers of banners
var slump = Math.random();
var talet = Math.round(slump * (a-1))+1;
function create() {

this.width = ''
this.height = ''
this.src = ''
this.href = ''
this.border = ''
this.alt = ''
this.under = ''
}

b = new Array()
for(var i=1; i<=a; i++) { b[i] = new create() }
b[1].src = "blog/template/stariver42/header.jpg"
b[1].href = "#top"
b[1].width = "700"
b[1].height = "200"
b[1].border = "0"
b[1].alt = "欢迎光临竹园下!"

b[2].src = "blog/template/stariver42/header1.jpg"
b[2].href = "#top"
b[2].width = "700"
b[2].height = "200"
b[2].border = "0"
b[2].alt = "Welcome_To_Totti's_Blog!"

b[3].src = "blog/template/stariver42/header2.jpg"
b[3].href = "#top"
b[3].width = "700"
b[3].height = "200"
b[3].border = "0"
b[3].alt = "竹园下-记录着我的生活,收集着我的收集" 

b[4].src = "blog/template/stariver42/header3.jpg"
b[4].href = "#top"
b[4].width = "700"
b[4].height = "200"
b[4].border = "0"
b[4].alt = "竹园下-如风一般的轻盈~" 

var visa = "";

visa += '<a href="'+b[talet].href+'">'
visa += '<img src="'+b[talet].src+'" height='+b[talet].height
visa += ' width='+b[talet].width+' border='+b[talet].border+' alt='+b[talet].alt+'>';
visa += '</a>'
//-->
</SCRIPT><script language="JavaScript">
<!--
document.write('<CENTER>'+visa+'<br>');
document.write(b[talet].under+'</center>');
//--></script>


要点:修改其中每个图形的位置,链接,尺寸,边缘,显示文字和文字超链接。

收集 | 评论(0) | 引用(0) | 阅读(2899)
发表评论
昵称

网址

电邮
打开HTML 打开UBB 表情 打开表情 隐藏 记住我 [注册]