爱东东

VS.NET,IT,个人,个人网站 爱东东 http://www.idongdong.net

 

自己写的bannerJS代码

function CImg(pDivName,pImgUrl,pWidth,pHeigth,pActionUrl,pAction,pIsClickAction){
 this.DivName=pDivName;
 this.ImgUrl=pImgUrl.toLowerCase();
 this.Width=pWidth;
 this.Heigth=pHeigth;
 this.Action=pAction;
 this.ActionUrl=pActionUrl;
 this.IsClickAction=pIsClickAction;
 var imgurlsrc=this.ImgUrl;
 document.getElementById(this.DivName).style.zIndex=10;
 if(imgurlsrc.substring(imgurlsrc.length - 4)==".swf"){
  if(this.IsClickAction==true){
   document.getElementById(this.DivName).innerHTML="<a href=\""+this.ActionUrl+"\" onclick=\""+this.Action+"\" target=_blank><object classid=\"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\" codebase=\"http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=5,0,0,0\" width=\""+this.Width+"\" height=\""+this.Heigth+"\"> <param name=movie value=\""+this.ImgUrl+"\"> <param name=quality value=high> <param name=\"wmode\" value=\"transparent\"></object></a>";
  }else{
   document.getElementById(this.DivName).innerHTML="<a href=\""+this.ActionUrl+"\" target=_blank><object classid=\"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\" codebase=\"http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=5,0,0,0\" width=\""+this.Width+"\" height=\""+this.Heigth+"\"> <param name=movie value=\""+this.ImgUrl+"\"> <param name=quality value=high> <param name=\"wmode\" value=\"transparent\"></object></a>";
  }
 }else{
  if(pIsClickAction==true){
   document.getElementById(this.DivName).innerHTML="<a href=\""+this.ActionUrl+"\" onclick=\""+this.Action+"\" target=_blank><img src=\""+this.ImgUrl+"\" width="+this.Width+" height="+this.Heigth+"></img></a>";
  }else{
   document.getElementById(this.DivName).innerHTML="<a href=\""+this.ActionUrl+"\" target=_blank><img src=\""+this.ImgUrl+"\" width="+this.Width+" height="+this.Heigth+"></img></a>";
  }
 }
 if(this.IsClickAction==false){
  window.setTimeout(this.Action,1);
 }
}
---------------------------------------------
使用时只需要 var c=CImg(pDivName,pImgUrl,pWidth,pHeigth,pActionUrl,pAction,pIsClickAction);即可
pDivName:=div名称,banner需要附着于一个div
pImgUrl:=banner对应的图片url,可以是图片也可以是swf
pWidth,pHeigth:=banner尺寸
pActionUrl:=点击banner时的弹出的链接,可以为"",对于图片可以,对于swf需要swf自己处理了
pIsClickAction:=是否在点击banner时执行 pAction 中的代码(应该为js的function名称),true表示点击时执行,false,则为展现banner时执行
pAction:=点击banner时需要做的动作,对应js的function名称,可以为""

posted on 2006-06-30 11:00  爱东东  阅读(359)  评论(0编辑  收藏  举报

导航