国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 語言 > JavaScript > 正文

js 左右懸浮對(duì)聯(lián)廣告代碼示例

2024-05-06 16:11:55
字體:
供稿:網(wǎng)友

這篇文章主要介紹了js 左右懸浮對(duì)聯(lián)廣告代碼示例,需要的朋友可以參考下

一段js 左右懸浮廣告代碼,只要修改廣告圖片地址與連接地址,相應(yīng)參數(shù)根據(jù)頁面調(diào)整下就可以使用這段左右懸浮廣告代碼了

代碼:

  1. var delta=0.15 
  2. var collection; 
  3. function floaters() { 
  4. this.items = ; 
  5. this.addItem = function(id,x,y,content) 
  6. 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>'); 
  7.  
  8. var newItem = {}; 
  9. newItem.object = document.getElementById(id); 
  10. newItem.x = x; 
  11. newItem.y = y; 
  12. this.items[this.items.length] = newItem; 
  13. this.play = function() 
  14. collection = this.items 
  15. setInterval('play()',10); 
  16. function play() 
  17. for(var i=0;i<collection.length;i++) 
  18. var followObj = collection[i].object; 
  19. var followObj_x = (typeof(collection[i].x)=='string'?eval(collection[i].x):collection[i].x); 
  20. var followObj_y = (typeof(collection[i].y)=='string'?eval(collection[i].y):collection[i].y); 
  21. if(followObj.offsetLeft!=(document.body.scrollLeft+followObj_x)) { 
  22. var dx=(document.body.scrollLeft+followObj_x-followObj.offsetLeft)*delta; 
  23. dx=(dx>0?1:-1)*Math.ceil(Math.abs(dx)); 
  24. followObj.style.left=followObj.offsetLeft+dx; 
  25. if(followObj.offsetTop!=(document.body.scrollTop+followObj_y)) { 
  26. var dy=(document.body.scrollTop+followObj_y-followObj.offsetTop)*delta; 
  27. dy=(dy>0?1:-1)*Math.ceil(Math.abs(dy)); 
  28. followObj.style.top=followObj.offsetTop+dy; 
  29. followObj.style.display = ''
  30. }  
  31.  
  32. var theFloaters = new floaters(); 
  33. theFloaters.addItem('followDiv1','document.body.clientWidth-112',230,'<a href=左鏈接地址 target=_blank><img src=左圖片地址 border=0></a>'); 
  34. theFloaters.addItem('followDiv2',12,230,'<a href=右鏈接地址 target=_blank><img src=右圖片地址 border=0></a>'); 
  35. theFloaters.play(); 

另存為*.js文件,在頁面中引用:調(diào)用即可,*代表你另存的文件名!

注意:修改廣告圖片地址和連接地址!相應(yīng)的參數(shù)可以根據(jù)頁面自行調(diào)整。

發(fā)表評(píng)論 共有條評(píng)論
用戶名: 密碼:
驗(yàn)證碼: 匿名發(fā)表

圖片精選

主站蜘蛛池模板: 毕节市| 保山市| 霍林郭勒市| 张家口市| 宁化县| 吉林市| 台南县| 荥阳市| 家居| 漳州市| 瑞昌市| 宜丰县| 广州市| 石渠县| 新和县| 蕉岭县| 政和县| 四子王旗| 澄城县| 洛宁县| 临夏县| 余江县| 林芝县| 呼和浩特市| 吴忠市| 开化县| 梓潼县| 保亭| 柞水县| 小金县| 新源县| 二连浩特市| 城市| 罗甸县| 犍为县| 嘉兴市| 台中市| 三穗县| 滁州市| 基隆市| 阜城县|