js| Ads | script | Show |js| ads | Scripts use AD modules when writing a project, in order not to use ASP to generate scripting code is more cumbersome, so the idea of writing a script class, that is, a class of scripting code to control all the display on the same page of the floating ads. But in the process of writing found that the JS script in the settimeout can not use the method of class. Strange, whether I was mistaken or JS script can not do this?? But the VBS script is OK! I faint ...
No, put the code:
[VBS script CODE]
The following is a code fragment:
'/**************** floating ads display class ****************************************************
'/* Author: The fish that died in the water
'/* scripting language: VBS
'/* Usage:
'/* Set adver1=new Adverclass
'/* adver1.objname= ' Adver1 ' sets the current object name [itself object variable name]
'/* adver1.imgtype=1 ' picture of type 0 = normal picture 1=flash animation
The width of the '/* adver1.imagewidth=299 ' picture
The height of the '/* adver1.imageheight=87 ' picture
'/* ### #以下方法显示广告图片 (Flash) object. printhtml "Picture address", "link address", "Hint info"
' * * adver1.printhtml "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/"," What is this? "
'/***********************************************************************************
Class Adverclass
Public divID
Public objname
Private Objdiv
Public Delay ' Change number
Public Imgtype
Private Istep
Private Itop,ileft,width,height
Private Topflag,leftflag
' The size of the advertising picture
Public Imagewidth,imageheight
Private Sub Class_Initialize
Randomize
Divid=int (Rnd (time) *9999+1)
Delay=80
Height=document.body.clientheight
Width=document.body.clientwidth
Itop=0
Ileft=0
Topflag=false:leftflag=false
Istep=3
Imgtype=0 ' 0 is picture 1 is a flash file
Imagewidth=0
Imageheight=0
End Sub
Private Sub Class_Terminate
End Sub
Public Sub scrollimg ()
Dim Offheight,offwidth,irnd
Offwidth=objdiv.offsetwidth
Offheight=objdiv.offsetheight
ObjDiv.style.left = ILeft + document.body.scrollLeft
ObjDiv.style.top = Itop + document.body.scrollTop
Irnd=int (Rnd (time) *99+1)
If irnd>97 Then Topflag=not Topflag
Irnd=int (Rnd (time) *9+1)
If irnd>98 Then Leftflag=not Leftflag
If Topflag Then
Itop=itop+istep*rnd (Time)
Else
Itop=itop-istep*rnd (Time)
End If
If Leftflag Then
Ileft=ileft+istep*rnd (Time)
Else
Ileft=ileft-istep*rnd (Time)
End If
If itop<0 Then
Itop=0
Topflag=true
ElseIf Itop>height-offheight Then
Itop=height-offheight
Topflag=false
End If
If ileft<0 Then
Ileft=0
Leftflag=true
ElseIf Ileft>width-offwidth Then
Ileft=width-offwidth
Leftflag=false
End If
End Sub
Private Sub Start ()
SetInterval objname& ". Scrollimg () ", Delay
End Sub
Public Sub printhtml (ByVal imgsrc,byval adhref,byval adtitle)
If imgtype=0 Then
Call Printimagehtml (Imgsrc,adhref,adtitle)
Else
Call Printflashhtml (Imgsrc,adhref,adtitle)
End If
Execute "Set objdiv=document.all.img" &divid
Ileft=int (Rnd (Time) * (Width-100) +1)
Itop=int (Rnd (Time) * (Height-100) +1)
Objdiv.style.top=itop
Objdiv.style.left=ileft
Call Start ()
End Sub
Private Sub printimagehtml (ByVal imgsrc,byval adhref,byval adtitle)
If imagewidth=0 Or not IsNumeric (imagewidth) Then
Imagewidth= ""
Else
Imagewidth= "Width= '" &ImageWidth& ""
End If
If imageheight=0 Or not IsNumeric (imageheight) Then
Imageheight= ""
Else
imageheight= "height= '" &ImageHeight& ""
End If
document.write "<div id=" "img" &DivID& "" "style=" "Position:absolute;" > "
document.write "<a href=" "&adHref&" "target=" "_blank" "title=" "&adTitle&" ">"
document.write "</a></div>"
End Sub
Private Sub printflashhtml (ByVal imgsrc,byval adhref,byval adtitle)
If imagewidth=0 Or not IsNumeric (imagewidth) Then
Imagewidth=80
End If
Imagewidth= "Width= '" &ImageWidth& "' &q