couplet | advertising
[General effect]
Now a lot of website advertising to do in full swing, now I would like to introduce the common couplet floating advertising effect of the code use method, introduced this effect, in the 1024*768 resolution of the normal display, in the 800*600 resolution can automatically hide, so as not to cover the page affect visitors browsing content, Here is the code needed to implement the effect:
var delta=0.015
var collection;
function Floaters () {
this.items = [];
this.additem = function (id,x,y,content)
{
document.write (' < DIV id= ' +id+ ' style= ' z-index:0; 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 () ', 10);
}
}
function Play ()
{
if (screen.width<=800)
{
for (var i=0;i<collection.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));