以下是 随机显示图片代码 的示例演示效果:
部分效果截图:
HTML代码(index.html):
<html>
<head>
<meta name="keywords" content="JS代码,图片特效,JS广告代码,JS特效代码" />
<meta name="description" content="此代码内容为随机显示图片代码,属于站长常用代码" />
<title>随机显示图片代码</title>
</head>
<body>
<script language="JavaScript">
var how_many_ads = 5
var now = new Date()
var sec = now.getSeconds()
var ad = sec % how_many_ads;
ad +=1;
if (ad==1){
url="#";
alt="ad1";
banner="images/01.jpg";
width="440";
height="230";
}
if (ad==2) {
url="#";
alt="ad2";
banner="images/02.jpg";
width="440";
height="230";
}
if (ad==3) {
url="#";
alt="ad3";
banner="images/03.jpg";
width="440";
height="230";
}
if (ad==4) {
url="#";
alt="ad4";
banner="images/04.jpg";
width="440";
height="230";
}
if (ad==5) {
url="#";
alt="ad5";
banner="images/05.jpg";
width="440";
height="230";
}
document.write('<center>');
document.write('<a href=\"' + url + '\" target=\"_blank\">');
document.write('<img src=\"' + banner + '\" width=')
document.write(width + ' height=' + height + ' ');
document.write('alt=\"' + alt + '\" border=0></a><br>');
document.write('</center>');
</script>
<br>
<br>
</body>
</html>