JavaScript让多个图片广告交替显示
本帖最后由 小麦子 于 2024-10-19 00:19 编辑JavaScript让多个Banner图片广告交替显示,如果你的站很牛,广告位被占满了,你可以考虑让多个图片广告轮番交替显示,链接也跟着变,这样是不是为你节省了宝贵的广告位?思路是好,但不知道广告效果是不是也一样好,这就需要实验了。演示如下:
<head>
<title>图片广告交替显示</title>
<script language="JavaScript" type="text/JavaScript">
<!--
var urlArray = new Array(3);
var banArray = new Array(3);
var counter = 1;
var url = "http://www.niuniubbs.com"; //initial URL
//add your necessary URL's
urlArray = "http://www.niuniubbs.com/player/";
urlArray = "http://www.niuniubbs.com/";
urlArray = "http://www.niuniubbs.com/webtx/";
if(document.images)
{
for(i = 0; i < 3; i++)
{
banArray = new Image(468, 60);
banArray.src = "http://www.niuniubbs.com/images/face/image" + (i+1) + ".gif";
}
}
function changeBanner()
{
if(counter > 2)
counter = 0;
document.banner.src = banArray.src; //sets a new banner
url = urlArray;
counter++;
}
var timer = window.setInterval("changeBanner()", 3000);
//-->
</script>
</head>
<body>
<a href="#"><img src="http://www.niuniubbs.com/mylogo2.gif" width=468 height=60 border=0 name="banner"></a>
</body>
</html>
页:
[1]