Maison >interface Web >js tutoriel >js code publicitaire de couplet flottant gauche et droit example_layout et couches

js code publicitaire de couplet flottant gauche et droit example_layout et couches

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBoriginal
2016-05-16 16:27:351579parcourir

Un code d'annonce flottant gauche et droit js, tant que vous modifiez l'adresse de l'image de l'annonce et l'adresse de connexion, et ajustez les paramètres correspondants en fonction de la page, vous pouvez utiliser ce code d'annonce flottant gauche et droit

Code :

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:80px; height:60px;left:'+(typeof(x)=='string'&#63;eval(x):x)+';top:'+(typeof(y)=='string'&#63;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'&#63;eval(collection[i].x):collection[i].x);
  var followObj_y = (typeof(collection[i].y)=='string'&#63;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&#63;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&#63;1:-1)*Math.ceil(Math.abs(dy));
   followObj.style.top=followObj.offsetTop+dy;
   }
  followObj.style.display = '';
  }
 } 
 
 var theFloaters = new floaters();
 theFloaters.addItem('followDiv1','document.body.clientWidth-112',230,'<a href=左链接地址 target=_blank><img  src="/static/imghwm/default1.png"  data-src="*.js"  class="lazy"  src=左图片地址 border=0 alt="js code publicitaire de couplet flottant gauche et droit example_layout et couches" ></a>');
 theFloaters.addItem('followDiv2',12,230,'<a href=右链接地址 target=_blank><img  src="/static/imghwm/default1.png"  data-src="*.js"  class="lazy"  src=右图片地址 border=0 alt="js code publicitaire de couplet flottant gauche et droit example_layout et couches" ></a>');
 theFloaters.play();

Enregistrez-le en tant que fichier *.js et citez-le sur la page : <script></script> Appelez-le simplement, * représente le nom du fichier que vous avez enregistré !
Remarque : Modifiez l'adresse de l'image publicitaire et l'adresse de connexion ! Les paramètres correspondants peuvent être ajustés en fonction de la page.

Déclaration:
Le contenu de cet article est volontairement contribué par les internautes et les droits d'auteur appartiennent à l'auteur original. Ce site n'assume aucune responsabilité légale correspondante. Si vous trouvez un contenu suspecté de plagiat ou de contrefaçon, veuillez contacter admin@php.cn