Floating ad js implementation _ ad code

Source: Internet
Author: User
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]

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.