Page Add Flare window (image link)

Source: Internet
Author: User

Requirements: Add a floating window on the homepage (actually a picture, click is an address link).

1. A section of JavaScript code found on the Web page is written as a JS file.

1 varRimifon = {2"Ads":NewObject,3"Newfloatad":function(Imgurl, strlink) {4         varAD = Document.createelement ("a");5Ad. Dirv =true;6Ad. DIRH =true;7Ad. Automove =true;8Ad. Image =NewImage;9Ad. Seed =math.random ();TenAd. Timer = SetInterval ("rimifon.float (" + AD. Seed + ")", 50); One          This. Ads[ad. Seed] =AD; AAd. Image.parent =AD; -Ad.style.position = "Absolute"; -Ad.style.left = 0; theAd.style.top = 0; -         ad.style.zindex=999999; -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; AAd. Image.border = 0; atAd.target = "_blank"; -         } - Ad.appendchild (AD. Image); - Document.body.appendChild (AD); -         returnAD; -     }, in"Float":function(Floatid) { -         varAD = This. Ads[floatid]; to         if(AD. Automove) { +             varCurleft =parseint (ad.style.left); -             varCurtop =parseint (ad.style.top); the             if(Ad.offsetwidth + curleft > document.body.clientWidth + document.body.scrollleft-1) { *Curleft = Document.body.scrollLeft + Document.body.clientWidth-Ad.offsetwidth; $Ad. DIRH =false;Panax Notoginseng             } -             if(Ad.offsetheight + curtop > document.body.clientHeight + document.body.scrolltop-1) { theCurtop = Document.body.scrollTop + Document.body.clientHeight-Ad.offsetheight; +Ad. Dirv =false; A             } the             if(Curleft <document.body.scrollLeft) { +Curleft =Document.body.scrollLeft; -Ad. DIRH =true; $             } $             if(Curtop <document.body.scrollTop) { -Curtop =Document.body.scrollTop; -Ad. Dirv =true; the             } -Ad.style.left = Curleft + (AD. Dirh? 1:-1) + "px";WuyiAd.style.top = Curtop + (AD. Dirv? 1:-1) + "px"; the         } -     } Wu}

Note: after adding to the specific. aspx page, it is found that because there are too many div in the page, the picture is not at the top (embarrassing). Baidu, said to change the value of Z-index (CSS properties), such as set to z-index:9999; After setting or not, finally found a professional art (thank Kwantip), the art of Reading JS, said JS problem, in 16 lines added ad.style.zindex=999999; The test was successful.
2. Page

<script type= "Text/javascript" src= "Js/piao.js" ></script>

3. Page <body> add specific div implementation.

1 <div style= "width:10px;height:10px;" >2     <script type= "Text/javascript" >3         Rimifon.newfloatad ("Img/0biye/0.jpg", " front/tdodetail.aspx?type=source&id=73 "4     5  </div>

Note:. The two parameters in the Newfloatad ("Picture address", "link address") function are the picture address and the link address, respectively.

Page Add Flare window (image link)

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.