点击这里给我发消息 点击这里给我发消息

网页特效:一种很酷的图片动态切换效果

添加时间:2010-1-5
    相关阅读: 网页 页面 链接

第一步、把下面这段代码插入到页面的<head>与</head>之间:

<script language=javascript>
isns = navigator.appName == "Netscape";
function ztstr(id,picurl,linkurl)
{
this.id=id
this.picurl=picurl
this.linkurl=linkurl
}

zhuanti=new Array()
imgcount=1;
frequency=10*1000;//30秒

//在这里修改图片的路径和链接
zhuanti[1]=new ztstr('1','http://www.gaowin.com/design/RoUpFiles/../Files/RoUpFiles/eraBanner1.gif','http://www.windstudio.net')
zhuanti[2]=new ztstr('2','http://www.gaowin.com/design/RoUpFiles/../Files/RoUpFiles/eraBanner2.gif','http://www.windstudio.net')
zhuanti[3]=new ztstr('3','http://www.gaowin.com/design/RoUpFiles/../Files/RoUpFiles/eraBanner3.gif','http://www.windstudio.net')
zhuanti[4]=new ztstr('4','http://www.gaowin.com/design/RoUpFiles/../Files/RoUpFiles/eraBanner4.gif','http://www.windstudio.net')

imgcount=zhuanti.length-1
for(i=1;i<=imgcount;i++)
{
eval("img"+i+"=new Image()")
eval("img"+i+".src=zhuanti["+i+"].picurl")
}

nn=1

var rand1 = 0;
var useRand = 0;

function swapPic() {
var imgnum = zhuanti.length - 1;
do {
var randnum = Math.random();
rand1 = Math.round((imgnum - 1) * randnum) + 1;
} while (rand1 == useRand);
useRand = rand1;
// alert(useRand);
nn=useRand;
change_img();
}

function change_img()
{
eval('document.pic.src=img'+nn+'.src');
nn++;
if(nn>imgcount) nn=1
if(!isns)
{
pic.filters.item(0).apply()
pic.style.visibility='visible'
pic.filters.item(0).play()
setTimeout("pic.style.visibility='hidden'",frequency);
}
else
document.pic.visibility='visible'
tt=setTimeout('change_img()',frequency)
}

function pictarget()
{
tt=nn-1
if(tt<1) tt=imgcount
cururl=zhuanti[tt].linkurl
window.open(cururl);
}
function ini()
{
if(!isns)
{
spacewidth=Math.round((divmask.offsetWidth-770)/2)
dmwidth=770+spacewidth
dmheight=divmask.offsetHeight
totalstep=50
timeout=50
dmstepw=Math.round(770/totalstep)
dmsteph=Math.round(dmheight/totalstep)
setTimeout('hidimg()',3000)
}
else swapPic()
}

function hidimg()
{
dmwidth-=dmstepw
dmheight-=dmsteph
eval('divmask.style.clip="rect(0,'+dmwidth+','+dmheight+',0)"')
hdrun=setTimeout('hidimg()',timeout)
if(dmwidth<=spacewidth&&dmheight<=0)
{
divmask.style.visibility='hidden'
clearTimeout(hdrun)
swapPic()
}
}
</script>

第二步、调用定义好的javascript函数,在<body>里加上以下代码:

<body onload=swapPic()>

第三步、在页面中插入图片和链接:

<a href=javascript:void(null) onclick='javascript:pictarget();return false;'><img src="http://www.gaowin.com/design/RoUpFiles/../Files/RoUpFiles/erabanner1.gif" width=468 height=60 border=0 name=pic style="visibility:hidden;filter:revealtrans(duration=2.0,transition=12)"></a>

好,到这里就大功告成了。另外,试试改变transition的数值,可以得到不同的转换效果哟~~

 

本文作者:
咨询热线:020-85648757 85648755 85648616 0755-27912581 客服:020-85648756 0755-27912581 业务传真:020-32579052
广州市网景网络科技有限公司 Copyright◎2003-2008 Veelink.com. All Rights Reserved.
广州商务地址:广东省广州市黄埔大道中203号(海景园区)海景花园C栋501室
= 深圳商务地址:深圳市宝源路华丰宝源大厦606
研发中心:广东广州市天河软件园海景园区 粤ICP备05103322号 工商注册