(Original) floating advertisement display script (VBS, JS dual version)

xiaoxiao2021-03-06  104

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 "

"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 "
"document.write" "Document.write" "document.write" "document.write" "Document.write" "End Subend Class [JS Scripts] // **************** Floating Ads Show ***************** ********************************* * // author: fish dead in the water // * scripting language: JavaScript // * Usage: // * var adver = new AdverClass // * adj; // This sentence cannot be setTime So no use // * adver.setdivid (1); // This sentence is not available // * Adver.setimageType (1); // is an ordinary picture when set to 0 or if this sentence is not written, 1 is Flash animation file // * Adver.setimagepx (299, 87); // Set the picture Width and height // * Adver.showadver ("http://edu.qq.com/flash/moto-button.swf", "http://www.chinese.bj.cn/", "What is this? ); // * var adver1 = new AdverClass (); // * Adver1.showadver ("img.gif", "http://www.chinese.bj.cn/" "What is"); // * SetTimer (); // * // Because the class cannot write setTime so I have to write -_- ## (VBS script can be.

I fell) // * function setTimer () {// * adver.floatscroll (); // * Adver1.floatScroll (); // * setTimeout ("Settimer ()", 80); // *} // * *********************************************************** ********************************* 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; // Time delay value var Topstep = 2, leftstep = 3; // Step How many var inter; // This is the only value of the outside of the DIVID can ensure that the layer's ID is unique Divid = math.round (math.random () * 100000) // Advertising type 0 = normal picture 1 = flash ad picture.setimageType = function (stype) {if (stype! = 1 && style! = 0) {Stype = 0;}} iMageType = stype;} // External calling variable name this.setobjName = function (sname) {objName = sname;} // Advertising picture height and width this.setimagepx = function (iWidth, Iheight) {IF ISNAN (iWidth) {imagewidth = iWidth;} else {imagewidth = 0;}}} (! isnan (iHEIGHT)) {imageHeight = IHEIGHT;} else {imageheight = 0 }}} // Set the ID value of the advertisement this.SetdiD = function (idiv) {divId = idiv;} // master function, display advertisement code this.showadver = function (Adimgsrc, Adhref, Adtitle {IF (iMageType) == 0) {Showimagehtml (Adimgsrc, Adhref, Adtitle);} else {showflashhtml (adimgsrc, adhref, adtitle);} evAl ("objdiv = Document.all.img" Divid ";"); // get a picture Width OFFWIDTH = Objdiv.offSetWidth; OffHeight = Objdiv.offsetHeight; // Random Displays the start position ILEFT = math.Round (Math.random ()); ITOP = Math.Round (Math.random ) * (HEIGHT-OFFHEIGHT);

Objdiv.style.pixelleft = ilt; objdiv.style.pixeltop = ket; // Timed start // startTimer ();} // main function, floating swimming display advertisement this.floatscroll = function () {var IRND; IRND = Math.Round (Math.random () * 100); // This value is to generate different track IF (Objdiv == null) returnft = Ileft Document.body when multiple maps are displayed. Scrollleft; objdiv.style.pixeltop = itop document.body.scrolltop; if (Irnd> 98) {leftflag =! leftflag;} Irnd = Math.Round (math.random () * 100); if (Irnd> 99) {TOPFLAG =! Topflag;}} {iLEFT = ILEFT Leftstep * math.random ();} else {ileft = ileft-leftstep * math.random ();} if (topflag) {ket = ITOP TOPSTEP * Math.random ();} else {itop = itop-Topstep * math.random ();} if (ileft <0) {iLEFT = 0; leftflag = true;} else if (ileft> width-offidth) {ileft = Width-offwidth; leftflag = false;} f (ITOP <0) {ket = 0; Topflag = true;} else if (ITOP> Height-OffHeight) {Itop = Height-OffHeight; Topflag = false;}} // Timed mobile ads Picture of Function ST ArtTimer () {if (objName == ") Return; // Alert (ObjName ". floatscroll (); "); //inter=setinterval (ObjName ".floatscroll()", intelay);} // Show picture HTML code function showImageHtml (adImgSrc, adHref, adTitle) {var sWidth, sHeight; if (imageWidth <5) {sWidth = "";} else {sWidth = "width = '" imageWidth "'";} if (imageHeight <5) {Sheight = "";} else {sheight = "height = '" imageheight "} Document.write ("

"); Document.write (""); Document.write (" ");} // Display flash file HTML code function showFlashHtml (adImgSrc, adHref, adTitle) {var sWidth, sHeight; if (imageWidth <5) {sWidth = "width = '80 '";} else {sWidth = "width ='" imageWidth " '"; } IF (ImageHeight <5) {sheight = "height = '80 '";} else {sheight = "height ='" imageHeight "} Document.write ("
"); Document.write (" " ); Document.write (""); Document.write (" "); Document.write (" ");}} Sample code (including two scripts): floating ad display script Class Demo </ Title> </ head> <body> <! <! <! <Script language = "vbscript" src = "adjipbs.vbs"> </ script> <script Language = "vbscript"> DIM Adver, Adver1Set Adver = New AdverClassadver.objName = "Adver" adver.divid = 20ADVER.PRINTHTML "img.gif", "http://www.chinese.bj.cn/", "this What is "Set Adver1 = New AdverClassAdver1.ObjName =" Adver1 "Adver1.ImgType = 1Adver1.ImageWidth = 299Adver1.ImageHeight = 87Adver1.PrintHtml" http://edu.qq.com/flash/moto-button.swf "," Http://www.chinese.bj.cn/ "" "What is" </ script> <! - JS Scripting Edition Advertising Class Sample Program -> <script language = "JavaScript" src = "AdverClass .js "> </ script> <script language =" javascript "> var adver = new adverclass (); adver.setobjname (" Adver "); adver.setdivid (1); adver.setimageType (1); adver.setimagepx (299, 87); adver.showadver ("http://edu.qq.com/flash/moto-butt ON.SWF "," http://www.chinese.bj.cn/ "," What is this "); var adver1 = new adverclass (); adver1.showadver (" img.gif "," http: // www.chinese.bj.cn/ "" What is "); setTimer (); function setTimer () {adver.floatscroll (); adver1.floatscroll (); settimeout (" setTimer () ", 80);} </ Script> </ body> </ html></p></div><div class="text-center mt-3 text-grey"> 转载请注明原文地址:https://www.9cbs.com/read-103568.html</div><div class="plugin d-flex justify-content-center mt-3"></div><hr><div class="row"><div class="col-lg-12 text-muted mt-2"><i class="icon-tags mr-2"></i><span class="badge border border-secondary mr-2"><h2 class="h6 mb-0 small"><a class="text-secondary" href="tag-2.html">9cbs</a></h2></span></div></div></div></div><div class="card card-postlist border-white shadow"><div class="card-body"><div class="card-title"><div class="d-flex justify-content-between"><div><b>New Post</b>(<span class="posts">0</span>) </div><div></div></div></div><ul class="postlist list-unstyled"> </ul></div></div><div class="d-none threadlist"><input type="checkbox" name="modtid" value="103568" checked /></div></div></div></div></div><footer class="text-muted small bg-dark py-4 mt-3" id="footer"><div class="container"><div class="row"><div class="col">CopyRight © 2020 All Rights Reserved </div><div class="col text-right">Processed: <b>0.035</b>, SQL: <b>9</b></div></div></div></footer><script src="./lang/en-us/lang.js?2.2.0"></script><script src="view/js/jquery.min.js?2.2.0"></script><script src="view/js/popper.min.js?2.2.0"></script><script src="view/js/bootstrap.min.js?2.2.0"></script><script src="view/js/xiuno.js?2.2.0"></script><script src="view/js/bootstrap-plugin.js?2.2.0"></script><script src="view/js/async.min.js?2.2.0"></script><script src="view/js/form.js?2.2.0"></script><script> var debug = DEBUG = 0; var url_rewrite_on = 1; var url_path = './'; var forumarr = {"1":"Tech"}; var fid = 1; var uid = 0; var gid = 0; xn.options.water_image_url = 'view/img/water-small.png'; </script><script src="view/js/wellcms.js?2.2.0"></script><a class="scroll-to-top rounded" href="javascript:void(0);"><i class="icon-angle-up"></i></a><a class="scroll-to-bottom rounded" href="javascript:void(0);" style="display: inline;"><i class="icon-angle-down"></i></a></body></html><script> var forum_url = 'list-1.html'; var safe_token = 'Eke2z2ncZd_2Bfc0tUlE_2F_2BCFa_2FZ7fP6XIxkcgfGuAC70x_2BEhdpg2k0ISnGm8YgIcuBeSeCuG9w2P4QPQD3HeJm8w_3D_3D'; var body = $('body'); body.on('submit', '#form', function() { var jthis = $(this); var jsubmit = jthis.find('#submit'); jthis.reset(); jsubmit.button('loading'); var postdata = jthis.serializeObject(); $.xpost(jthis.attr('action'), postdata, function(code, message) { if(code == 0) { location.reload(); } else { $.alert(message); jsubmit.button('reset'); } }); return false; }); function resize_image() { var jmessagelist = $('div.message'); var first_width = jmessagelist.width(); jmessagelist.each(function() { var jdiv = $(this); var maxwidth = jdiv.attr('isfirst') ? first_width : jdiv.width(); var jmessage_width = Math.min(jdiv.width(), maxwidth); jdiv.find('img, embed, iframe, video').each(function() { var jimg = $(this); var img_width = this.org_width; var img_height = this.org_height; if(!img_width) { var img_width = jimg.attr('width'); var img_height = jimg.attr('height'); this.org_width = img_width; this.org_height = img_height; } if(img_width > jmessage_width) { if(this.tagName == 'IMG') { jimg.width(jmessage_width); jimg.css('height', 'auto'); jimg.css('cursor', 'pointer'); jimg.on('click', function() { }); } else { jimg.width(jmessage_width); var height = (img_height / img_width) * jimg.width(); jimg.height(height); } } }); }); } function resize_table() { $('div.message').each(function() { var jdiv = $(this); jdiv.find('table').addClass('table').wrap('<div class="table-responsive"></div>'); }); } $(function() { resize_image(); resize_table(); $(window).on('resize', resize_image); }); var jmessage = $('#message'); jmessage.on('focus', function() {if(jmessage.t) { clearTimeout(jmessage.t); jmessage.t = null; } jmessage.css('height', '6rem'); }); jmessage.on('blur', function() {jmessage.t = setTimeout(function() { jmessage.css('height', '2.5rem');}, 1000); }); $('#nav li[data-active="fid-1"]').addClass('active'); </script>