When writing a project, you should use the ad module, in order to use the ASP to generate script code, it is more troublesome when you generate script code, so you have a thought of writing, that is, use a class module script code to control all floating advertisements displayed on the same page. . However, in the process of writing, the JS script is found to use the class method in SetTimeout. Strange, is it what I made wrong or a JS script? ? But the VBS script can! I am dizzy ...
Don't say, post code: [VBS script code] '/ *************** Floating advertisement display class *************** ************************************ '/ * author: dead fish in water' / * script Language: VBS '/ * Usage:' / * SET Adver1 = New AdverClass' / * Adver1.objName = "Adver1" Set the current object name [Bible object variable name] '/ * adj to = 1' image type 0 = Normal Picture 1 = Flash Animation '/ * Adver1.ImageWidth = 299' Image Width '/ * Adver1.imageHheight = 87' Image Hard '/ * #### The following method Show adaps (flash) object .printhtml "Picture Address", "Link Address", "Tips" '/ * adver1.Printhtml "http://edu.qq.com/flash/moto-button.swf", "http://www.chinese.bj . c / "What is this" '/ ************************************************** ************************************************************************** Class AdverClass Public Divid PUBLIC ObjName Private ObjDiv Public Delay 'changing the number of Public ImgType Private iStep Private iTop, iLeft, Width, Height Private TopFlag, LeftFlag' size of the ad images Public ImageWidth, ImageHeight Private Sub Class_Initialize Randomize divID = Int (Rnd (Time) * 9999 1) DELAY = 80 = Document.body.clientHeight Width = Document.body.clientWidth ITOP = 0 ift = 0 Topflag = false: Leftflag = false istep = 3 imgt Ype = 0 '0 is a picture 1 is 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 TON TOPFLAG = not topflag ignd = int (RND (TIME) * 9 1) if Irnd> 98 Then LEFTFLAG = NOT LEFTFLAG IF TOPFLAG THEN ITOP = ITOP ISTEP * RND (TIME) ELSE ITOP = ITOP-ITEP * RND (TIME) end if if limited * 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) Endiffute "set objdiv = document.all.img" & divid = int (rND (Width-100) 1) ITOP = INT (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> "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 & "'" If ImageHeight = 0 Or Not IsNumeric (ImageHeight) Then ImageHeight = 80 End If ImageHeight = "height = '" & ImageHeight & "'" document. WRITE "