代码区:
var adNum=0;
var buttonShow=1;//显示按扭开关 1:显示 0:不显示
if(imgUrl.length>2) buttonShow=1; else buttonShow=0; //自动判断是否显示按扭
//var buttonPos=1;//按扭显示位置 1:右上 2:右下 3:左上 4:左下
var buttonX;//按扭X坐标
var buttonY;//按扭Y坐标
//var imgUrl=new Array();
//var imgLink=new Array();
//var text=new Array();
var imgPre=new Array();
var dakularCode="";//将生成按扭HTML代码
var adNum=0;
//imgUrl[1]="http://img.hc360.com/pf/Info/images/toutiao_050628_1.jpg";
//imgLink[1]="http://info.pf.hc360.com/html/001/012/001/36401.htm";
//text[1]="汽巴精化:研发中心上海启动";
for (i=1;i<8;i++)
{
imgPre[i]=new Image();
imgPre[i].src=imgUrl[i];
}
function setTransition()
{
if (document.all)
{
imgUrlrotator.filters.revealTrans.Transition=23;//Math.floor(Math.random()*23)
imgUrlrotator.filters.revealTrans.apply();
}
}
function playTransition()
{
if (document.all)
imgUrlrotator.filters.revealTrans.play();
}
function nextAd(toNum)
{
if(adNum<imgUrl.length-1)
adNum++ ;
else
adNum=1;
if(toNum!=null) adNum=toNum;
setTransition();
document.images.imgUrlrotator.src=imgUrl[adNum];
document.images.imgUrlrotator.alt=text[adNum];
//如果要显示文字标题,取消下面的注释
//document.getElementById('linktext').innerHTML="<a href="+imgLink[adNum]+" target=_blank class=px14-lh20>"+text[adNum]+"</a>";
playTransition();
if(buttonShow==1){checkButton();}
if(toNum!=null) toNum=null;
theTimer=setTimeout("nextAd()", 6000);
}
function jump2url()
{
jumpUrl=imgLink[adNum];jumpTarget='_blank';
if (jumpUrl != '')
{
if (jumpTarget != '')
window.open(jumpUrl,jumpTarget);
else location.href=jumpUrl;
}
}
function displayStatusMsg()
{
status=imgLink[adNum];
document.returnValue = true;
}
function checkButton()
{
for(i=1;i<=imgUrl.length-1;i++)
{if(i==adNum)
//document.getElementById('bt'+i).style.backgroundColor='#00FF00';
eval("bt"+i+".style.backgroundColor='#9B0000';bt"+i+".style.color='#FFFFFF';");
else
eval("bt"+i+".style.backgroundColor='#CCCCCC';bt"+i+".style.color='#000000';");
}
}
function dakularButtons()
{if(buttonShow==1){
//table的定位样式,用以消除错位的Bug!
//document.getElementById('newsTable').style.position="relative";
//document.getElementById('newsTable').style.top="0px";
switch(buttonPos){
case 1:{buttonX=194-imgUrl.length*20;buttonY=0;break;}
case 2:{buttonX=243-imgUrl.length*20;buttonY=182;break;}
case 3:{buttonX=imgUrl.length*20-100;buttonY=1;break;}
case 4:{buttonX=imgUrl.length*20-100;buttonY=182;break;}
default:{buttonX=243-imgUrl.length*20;buttonY=16;break;}
}
for(i=1;i<=imgUrl.length-1;i++)
{
dakularCode=dakularCode+"<div id='bt"+i+"' style='display:inline; height=14px; width:20px; border:1px solid #000000; background-color:#CCCCCC; color:#000000; font-size:12px; line-height:14px; filter: Alpha(Opacity=100);' align='center' onMouseOver=this.style.backgroundColor='#FFFFFF';this.style.color='#000000';this.style.cursor='hand' onMouseOut=checkButton(); onClick='clearTimeout(theTimer);nextAd("+i+");'>"+i+"</div>";
}
dakularCode="<div style='display:inline; position:relative;left:"+buttonX+"px; top:"+buttonY+"px; z-index:1;'>"+dakularCode+"</div>"
document.write(dakularCode);
}
}
调用区:
<script language=javascript src=timg/hc360news.js></script><script language="javascript">dakularButtons();</script>
<table id=newsTable border="0" cellspacing="0" cellpadding="0" width="172" height="121" style="margin-top:-15px">
<tr><td><a onMouseOver="displayStatusMsg();return document.returnValue" onMouseOut="status='';" href="javascript:jump2url()"><img style="FILTER: revealTrans(duration=1,transition=23); border:1px solid #000000" src="javascript:nextAd()" width=172 height=121 border=0 name=imgUrlrotator alt=""></a></td>
</tr>
</table>