Floating advertisement js implementation
Script var Rimifon = {"Ads": new Object, "NewFloatAd": function (imgUrl, strLink) {var ad = document. createElement ("a"); ad. dirV = true; ad. dirH = true; ad. autoMove = true; ad. image = new Image; ad. seed = Math. random (); ad. timer = setInterval ("Rimifon. float ("+ ad. seed + ")", 50); this. ads [ad. seed] = ad; ad. image. parent = ad; ad. style. position = "absolute"; ad. style. left = 0; ad. style. top = 0; Ad. image. src = imgUrl; ad. image. onmouseover = function () {this. parent. autoMove = false;} ad. image. onmouseout = function () {this. parent. autoMove = true;} if (strLink) {ad. href = strLink; ad. image. border = 0; ad.tar get = "_ blank";} ad. appendChild (ad. image); document. body. appendChild (ad); return ad;}, "Float": function (floatId) {var ad = this. ads [floatId]; if (ad. autoMove) {var curLeft = parseInt (Ad. style. left); var curTop = parseInt (ad. style. top); if (ad. offsetWidth + curLeft> document. body. clientWidth + document. body. scrollLeft-1) {curLeft = document. body. scrollLeft + document. body. clientWidth-ad. offsetWidth; ad. dirH = false;} if (ad. offsetHeight + curTop> document. body. clientHeight + document. body. scrollTop-1) {curTop = document. body. scrollTop + document. body. clientHeight-ad. OffsetHeight; ad. dirV = false;} if (curLeft <document. body. scrollLeft) {curLeft = document. body. scrollLeft; ad. dirH = true;} if (curTop <document. body. scrollTop) {curTop = document. body. scrollTop; ad. dirV = true;} ad. style. left = curLeft + (ad. dirH? 1:-1) + "px"; ad. style. top = curTop + (ad. DirV? 1:-1) + "px" ;}} script <body> <p style = "width: 30 cm; height: 40 cm "> </p> </body> script Rimifon. newFloatAd (" http://www.jb51.net/logos.gif "," http://www.baidu.com "); Var ad = Rimifon. NewFloatAd (" http://www.jb51.net/logos.gif "); Ad. style. left = 500; ad. style. top = 456; ad. Image. width = 88; ad. Image. height = 31; script
[Ctrl + A select all Note: If you need to introduce external Js, You need to refresh it to execute]