打印本文 打印本文 关闭窗口 关闭窗口
飘浮广告显示脚本类(VBS,JS双版)
作者:武汉SEO闵涛  文章来源:敏韬网  点击数2541  更新时间:2009/4/23 15:41:38  文章录入:mintao  责任编辑:mintao
''"
     If ImageHeight=0 Or Not IsNumeric(ImageHeight) Then
     ImageHeight=80
  End If
  ImageHeight=" height=''''"&ImageHeight&"''''"
  document.write "<div id=""img"&DivID&""" style=""position:absolute;"">"
  document.write "<a href="""&adHref&""" target=""_blank"" title=''''"&adTitle&"''''>"
  document.write "<object  codebase=''''http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0''''"&ImageWidth&ImageHeight&" align=''''middle''''>"
  document.write "<param name=''''movie'''' value=''''"&ImgSrc&"''''>"
  document.write "<param name=''''quality'''' value=''''high''''>"
  document.write "<embed src=''''"&ImgSrc&"''''"&ImageWidth&ImageHeight&" quality=''''high'''' pluginspage=''''http://www.macromedia.com/go/getflashplayer&#39; type=''''application/x-shockwave-flash''''></embed></object>"
  document.write "</a></div>"
    End Sub
End Class

[JS脚本]

以下是代码片段:
file://*****************漂浮广告显示类****************************************************
file://* 作者:死在水中的鱼
file://* 脚本语言:Javascript
file://* 用法: 
file://* var adver=new adverClass
file://* adver.setObjName("adver"); file://这句不能setTime所以没有用
file://* adver.setDivID(1);   file://这句可以不用
file://* adver.setImageType(1);     file://设为0时或不写这句时则是普通图片,1则为Flash动画文件
file://* adver.setImagePX(299,87);  file://设置图片的宽度与高度
file://* adver.showAdver("http://edu.qq.com/flash/moto-button.swf","http://www.chinese.bj.cn/'''' target="_blank" >http://edu.qq.com/flash/moto-button.swf","http://www.chinese.bj.cn/","这是什么");
file://* var adver1=new adverClass();
file://* adver1.showAdver("img.gif","http://www.chinese.bj.cn/","这是什么");
file://* setTimer();
file://* file://因为类里不能写setTime所以只好拿出来写-_-##(VBS脚本竟然可以。我倒)
file://* function setTimer(){
file://*   adver.floatScroll();
file://*   adver1.floatScroll();
file://*   setTimeout("setTimer()",80);
file://* }
file://***********************************************************************************
function adverClass(){
 var objName="";
 var imageType=0;
 var imageWidth=imageHeight=0;
 var iTop=iLeft=0;
 var topFlag=leftFlag=false;
 var divID=0,objDiv=null;
 var offWidth=offHeight=0;
 var width=document.body.clientWidth;
 var height=document.body.clientHeight;
 var delay=30;    file://时间的延迟值
 var topStep=2,leftStep=3;      file://一步跨多少
 var inter;
 file://此处是当外部不设置divID的值能够确保层的ID是唯一
 divID=Math.round(Math.random()*100000)
 file://广告的类型 0=普通图片    1=Flash广告图片
 this.setImageType=function(sType){
   if(sType!=1&&sType!=0){sType=0;}
   imageType=sType;
 }
    file://外部调用的变量名
 this.setObjName=function(sName){objName=sName;}
 file://广告图片的高度与宽度
 this.setImagePX=function(iWidth,iHeight){
   if(!isNaN(iWidth)){
      imageWidth=iWidth;
   }else{
      imageWidth=0;
   }
   if(!isNaN(iHeight)){
      imageHeight=iHeight;
   }else{
      imageHeight=0;
   }
 }
 file://设置广告所在层的ID值
 this.setDivID=function(iDiv){divID=iDiv;}
 
    file://主函数,显示广告代码
 this.showAdver=function(adImgSrc,adHref,adTitle){
    if(imageType==0){
       showImageHtml(adImgSrc,adHref,adTitle);
    }else{
       showFlashHtml(adImgSrc,adHref,adTitle);
    }
    eval("objDiv=document.all.img"+divID+";");
    file://取得图片的宽度
    offWidth=objDiv.offsetWidth;
    offHeight=objDiv.offsetHeight;
    file://随机显示广告的开始位置
    iLeft=Math.round(Math.random()*(width-offWidth));
    iTop=Math.round(Math.random()*(height-offHeight));
    objDiv.style.pixelLeft=iLeft;
    objDiv.style.pixelTop=iTop;
    file://定时开始
    file://startTimer();
 }
 file://主函数,漂浮游动显示广告
 this.floatScroll=function(){
    var iRnd;
    iRnd=Math.round(Math.random()*100);    file://此值是为了能使多图显示时产生不同的轨迹
    if(objDiv==null)return;
    objDiv.style.pixelLeft = iLeft + document.body.scrollLeft;
    objDiv.style.pixelTop = iTop + document.body.scrollTop;
    if(iRnd>98){leftFlag=!leftFlag;}
    iRnd=Math.round(Math.random()*100);
    if(iRnd>99){topFlag=!topFlag;}
    if(leftFlag){
       iLeft=iLeft+leftStep*Math.random();
    }else{
       iLeft=iLeft-leftStep*Math.random();
    }
    if(topFlag){
       iTop=iTop+topStep*Math.random();
    }else{
       iTop=iTop-topStep*Math.random();
    }
    if(iLeft<0){
       iLeft=0;
    leftFlag=true;
     }
    else if(iLeft>width-offWidth){
       iLeft=width-offWidth;
    leftFlag=false;
    }
    if(iTop<0){
       iTop=0;
    topFlag=true;
     }
    else if(iTop>height-offHeight){
       iTop=height-offHeight;
    topFlag=false;
    }
 }
 file://定时移动广告的图片
 function startTimer(){
    if(objName=="")return;
    file://alert(objName+".floatScroll();");
    file://inter=setInterval(objName+".floatScroll()",delay);
 }
 file://显示图片的HTML代码
 function showImageHtml(adImgSrc,adHref,adTitle){
   var sWidth,sHeight;
   if(imageWidth<5){
     sWidth="";
   }else{
     sWidth=" width=''''"+imageWidth+"''''";
   }
   if(imageHeight<5){
     sHeight="";
   }else{
     sHeight=" height=''''"

上一页  [1] [2] [3]  下一页

打印本文 打印本文 关闭窗口 关闭窗口