宜昌本地软件开发与弱电工程服务商
项目咨询 · 快速响应

[JS]一个对联广告的代码完美兼容jquery框架

2016-10-13 00:16:48 点击量:59 标签: 收藏本文

  1. suspendcode="<DIV id=lovexin1 style='Z-INDEX: 10; LEFT: 6px; POSITION: absolute; TOP: 105px; width: 100px; height: 300px;'><img src='/player/uploads/allimg/140711/0Z0221407-0.gif' onClick='javascript:window.hide()' width='100' height='14' border='0' vspace='3' alt='关闭对联广告'><a href='http://cnrdn.com/axE4' target='_blank'><img src='/player/uploads/allimg/140711/0Z0222107-1.jpg' width='100' height='273' border='0'></a></DIV>"   
  2. document.write(suspendcode);   
  3.    
  4. suspendcode="<DIV id=lovexin2 style='Z-INDEX: 10; right: 10px; POSITION: absolute; TOP: 105px; width: 100px; height: 300px;'><img src='/player/uploads/allimg/140711/0Z0221407-0.gif' onClick='javascript:window.hide()' width='100' height='14' border='0' vspace='3' alt='关闭对联广告'><a href='http://cnrdn.com/axE4' target='_blank'><img src='/player/uploads/allimg/140711/0Z0222107-1.jpg' width='100' height='273' border='0'></a></DIV>"   
  5. document.write(suspendcode);   
  6. lastScrollY=0;   
  7. function heartBeat(){   
  8. diffY=document.documentElement.scrollTop;   
  9.    
  10. percent=.3*(diffY-lastScrollY);   
  11. if(percent>0)percent=Math.ceil(percent);   
  12. else percent=Math.floor(percent);   
  13. document.all.lovexin1.style.pixelTop+=percent;   
  14. document.all.lovexin2.style.pixelTop+=percent;   
  15. lastScrollYlastScrollY=lastScrollY+percent;   
  16. }   
  17. function hide()     
  18. {      
  19. lovexin1.style.visibility="hidden";    
  20. lovexin2.style.visibility="hidden";   
  21. }   
  22. window.setInterval("heartBeat()",1);   

[JS]一个对联广告的代码完美兼容jquery框架,保存为一个js文件,在页面中插入js文件即可.