JavaScript 和 jQuery 设置悬浮广告

来源:互联网 发布:淘宝dota2饰品靠谱么 编辑:程序博客网 时间:2024/04/28 07:59
jqueryvar $a1Top;var $a1Obj;$(document).ready(function(){$a1Top=$("#ad1").css("top");});$(window).scroll(function(){$("#ad1").css("top", parseInt($a1Top)+$(window).scrollTop());});JSvar a1Top;var a1Obj;function inix(){//获取a1Top的高度a1Obj=document.getElementById("ad1");if(a1Obj.currentStyle){a1Top=parseInt(a1Obj.currentStyle.top);}else{a1Top=parseInt(a1Obj.getComputedStyle(a1obj,null).top);}}function move(){a1Obj.style.top=a1Top+parseInt(document.documentElement.scrollTop)+"px";}window.onload=inix;window.onscroll=move;

 

引用 http://www.zhjie.net

原创粉丝点击