您的位置:寻梦网首页编程乐园CSS 初步DHTML动态效果实例
图片动态链接显示

上一页 返回目录 下一页

名称:

图片动态链接显示

实例:

教程: 1.将下面的代码加入html文件的<head>和</head>之间:

<script language="JavaScript">
<!-- Hide from old browsers
var i = 1;
banner1= new Image();
banner1.src = "
../images/p-logo1.gif";
banner2 = new Image();
banner2.src = "
../images/p-logo2.gif";
banner3 = new Image();
banner3.src = "
../images/p-logo3.gif";
banner4 = new Image();
banner4.src = "
../images/p-logo4.gif";
links = new Array
links[1] = "
http://picknet.kol.com.cn"
links[2] = "
http://coolsites.163.net"
links[3] = "
http://www.itunion.com"
links[4] = "
http://infocn.yeah.net"
description = new Array
description[1] = "
嘉星品网"
description[2] = "
酷噻推荐"
description[3] = "
星网资讯"
description[4] = "
佳页一品"
function startTime()
{
var time= new Date();
hours= time.getHours();
mins= time.getMinutes();
secs= time.getSeconds();
closeTime=hours*3600+mins*60+secs;
closeTime+=1;   
Timer();
}
function Timer()
{
var time= new Date();
hours= time.getHours();
mins= time.getMinutes();
secs= time.getSeconds();
curTime=hours*3600+mins*60+secs
if (curTime>=closeTime)
{
if (i < 4){    //
图形总数
i++;
document.banner.src = eval("banner" + i + ".src");
}
else{
i = 1;
document.banner.src = eval("banner" + i + ".src");
}
startTime();
}
else{
window.setTimeout("Timer()",1500)}
}
function clickLink()
{     top.location = links[i] }
function descript()
{     window.status = description[i] }
// --> </script>

2.将<bady>语句改为:<body  onLoad="startTime();">

3.将下面的代码加入<body>和</body>之间需要的地方

<table border="0" width="100%" cellspacing="0"
cellpadding="0">
<tr>
<td width="100%"><p align="center"><a href onClick="clickLink(); return false;"
onMouseOver="descript(); return true;" onMouseOut="window.status=''"><img
src="../images/p-logo1.gif" border="0" name="banner" WIDTH="100" HEIGHT="30"></a></td>
</tr>
</table>

 

说明:
修改上面红色部分的图片路径和超连接部分,就可以了。
上一页 返回目录 下一页