Code effects on both sides of the page for advertising (allow off)

Source: Internet
Author: User
Tags abs eval implement return string
Couplet | couplet Advertisement | page

Click here to view the effect

Now a lot of website advertising to do in full swing, now I would like to introduce the common couplet floating advertising effect code use method, this article describes this effect, in the 1024*768 resolution of the normal display, in the resolution of the 800*600 can automatically hide, so as not to cover the page affect visitors browsing content, And unlike the previous two code, a picture button is added below the ad map to allow visitors to click on the close ad picture, and the following text box is the code needed to implement the effect:

var delta=0.015;
var collection;
var Closeb=false;
function floaters () {
This.items = [];
This.additem = function (id,x,y,content)
{
document.write (' <div id= ' +id+ ' style= ' z-index:10; Position:absolute; width:80px; Height:60px;left: ' + (typeof (x) = = ' string '? Eval (x): x) + '; Top: ' + (typeof (y) = = ' string '? Eval (y): y) + ' "> ' +content+ ' </DIV> ');

var newitem = {};
Newitem.object = document.getElementById (ID);
newitem.x = x;
Newitem.y = y;

 this.items[this.items.length] = NewItem;
}
this.play = function ()
{
 collection = this.items
 setinterval (' Play () ', 30); br>}
}
Function Play ()
{
 if (screen.width<=800 | | closeb)
 {
for (Var i=0;i<col  lection.length;i++)
{
 collection[i].object.style.display = ' none ';
}
return;
 }  
 for (var i=0;i<collection.length;i++)
 {
var followobj = collection[i].object;
var followobj_x = (typeof (collection[i].x) = = ' String ' eval (collection[i].x): collection[i].x);
var followobj_y = (typeof (collection[i].y) = = ' string '? Eval (collection[i].y): COLLECTION[I].Y);

if (followobj.offsetleft!= (document.body.scrollleft+followobj_x)) {
var dx= (document.body.scrollleft+followobj_x-followobj.offsetleft) *delta;
dx= (dx>0?1:-1) *math.ceil (math.abs (DX));
FOLLOWOBJ.STYLE.LEFT=FOLLOWOBJ.OFFSETLEFT+DX;
}

if (followobj.offsettop!= (document.body.scrolltop+followobj_y)) {
var dy= (document.body.scrolltop+followobj_y-followobj.offsettop) *delta;
Dy= (dy>0?1:-1) *math.ceil (Math.Abs (dy));
Followobj.style.top=followobj.offsettop+dy;
}
FollowObj.style.display = ';
}
}
function Closebanner ()
{
Closeb=true;
Return
}

var thefloaters = new Floaters ();
//
Thefloaters.additem (' FollowDiv1 ', ' document.body.clientwidth-100 ', 0, ' <a href=http://www.webjx.com target=_ Blank></a><br> );
Thefloaters.additem (' FollowDiv2 ', 0,0, ' <a href=http://www.webjx.com target=_blank></a><br>Thefloaters.play ();

Save the above code as a JS file, and then in the page you want to implement this effect, use <script type= "Text/javascript" language= "javascript1.2" src= "*.js" ></script > Call can, * on behalf of your saved file name! Pay attention to change the advertising picture address and connection address!



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.