Last Update:2017-08-24
Source: Internet
Author: User
Keywords
Web page production
Ajax
javascript
<! DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 transitional//en" "Http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd <html xmlns= "http://www.w3.org/1999/xhtml" <head> <meta http-equiv= "Content-type" content= "HTML; charset=gb2312 "/> <title>javascript sliding into the advertising code </title> <script language=" JavaScript "> Var delta=0.15 var Collection function floaters () { this.items = []; this.additem = function (id,x,y,content) { document.write (' <div id= ' +id+ ' style= ' z-index:10; position:absolute; width:100px; Height:100px;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 () {
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 CloseAd1 () { followdiv1.style.visibility= ' hidden '; followdiv2.style.visibility= ' hidden ';} var thefloaters = new Floaters (); var adleft= ' <a href= "http://www.jzread.com" Target=_blank><img src=/banner/banner.gif ><br> '; var adright= ' <a href= "http://www.jzread.com" Target=_blank><img src=/banner/banner.gif ><br> <a href=javascript:closead1 () >x</a><br> '; Thefloaters.additem (' FollowDiv2 ', 15,125,adleft); Thefloaters.additem (' FollowDiv1 ', ' document.body.clientwidth-115 ', 125,adright); Thefloaters.play (); </SCRIPT> </head>
<body> </body> </html>