当前位置:编程学习 > html/css >>

随机显示广告条

答案:

将下列代码加入body所需区域中

<script LANGUAGE="javascript">
<!-- Begin
var how_many_ads = 4;
var now = new Date()
var sec = now.getSeconds()
var ad = sec % how_many_ads;
ad +=1;
if (ad==1) {
txt="你的说明一";
url="你的衔接一";
alt="图片一说明";
banner="你的图片一";
width="160";
height="55";
}
if (ad==2) {
txt="你的说明二";
url="你的衔接二";
alt="图片二说明";
banner="你的图片二";
width="160";
height="55";
}
if (ad==3) {
txt="你的说明三";
url="你的衔接三";
alt="图片三说明";
banner="你的图片三";
width="160";
height="55";
}
if (ad==4) {
txt="你的说明四";
url="你的衔接四";
alt="图片四说明";
banner="你的图片四";
width="160";
height="55";
}
document.write('<center>');
document.write('<a href=> document.write('<img src=\"' + banner + '\" width=')
document.write(width + ' height=' + height + ' ');
document.write('alt=\"' + alt + '\" border=0><br>');
document.write('<small>' + txt + '</small></a>');
document.write('</center>');
// End -->
</script>

很简单的说明:width="160"; height="55";图片宽160像素高55像素 
var how_many_ads = 4; 广告条总共4个 你可以修改成任意个数 同时要注意 if (ad==1) 到 if (ad==4) 
太简单了实在不明白可以回复此文章。或者和我联系QQ19807980

  

上一个:域名广告去除
下一个:随机显示图片

CopyRight © 2012 站长网 编程知识问答 www.zzzyk.com All Rights Reserved
部份技术文章来自网络,