码迷,mamicode.com
首页 > Web开发 > 详细

网页特效”漂浮广告代码”来回跳动的

时间:2014-05-23 06:58:38      阅读:330      评论:0      收藏:0      [点我收藏+]

标签:style   blog   c   java   tar   ext   

<div id="ad" style="position:absolute">
<a href="http://www.cnblog.com/wayne173" target="_blank">
<img src="http://static.cnblogs.com/images/adminlogo.gif" border="0">
</a></div>
<script type="text/javascript">
var x = 50,y = 60;
var xin = true, yin = true;
var step = 1;
var delay = 10;
var obj=document.getElementById("ad");
function floatAD() {
var L=T=0;
var R= document.body.clientWidth-obj.offsetWidth;
var B = document.body.clientHeight-obj.offsetHeight;
obj.style.left = x + document.body.scrollLeft + "px";
obj.style.top = y + document.body.scrollTop + "px";
x = x + step*(xin?1:-1);
if (x < L) { xin = true; x = L;}
if (x > R){ xin = false; x = R;}
y = y + step*(yin?1:-1);
if (y < T) { yin = true; y = T; }
if (y > B) { yin = false; y = B; }
}
var itl= setInterval(floatAD, delay);
obj.onmouseover=function(){clearInterval(itl);}
obj.onmouseout=function(){itl=setInterval(floatAD, delay);}
&lt;/script&gt;
&lt;SCRIPT LANGUAGE="JavaScript"&gt;
var s = "网页可见区域宽 :"+ document.body.clientWidth;
s += "\r\n网页可见区域高:"+ document.body.clientHeight;
s += "\r\n网页可见区域高:"+ document.body.offsetHeight +" (包括边线的宽)";
s += "\r\n网页正文全文宽:"+ document.body.scrollWidth;
s += "\r\n网页正文全文高:"+ document.body.scrollHeight;
s += "\r\n网页被卷去的高:"+ document.body.scrollTop;
s += "\r\n网页被卷去的左:"+ document.body.scrollLeft;
s += "\r\n网页正文部分上:"+ window.screenTop;
s += "\r\n网页正文部分左:"+ window.screenLeft;
s += "\r\n屏幕分辨率的高:"+ window.screen.height;
s += "\r\n屏幕分辨率的宽:"+ window.screen.width;
s += "\r\n屏幕可用工作区高度:"+ window.screen.availHeight;
s += "\r\n屏幕可用工作区宽度:"+ window.screen.availWidth;
document.write(s);
&lt;/script&gt;

 

http://www.cnblog.com/wayne173 //换成是漂浮图片点击后出现的页面,也就是点击后出现的详细的介绍页面

http://static.cnblogs.com/images/adminlogo.gif //换成是漂浮广告图片的URL地址,最好采用绝对路径
var x = 50,y = 60 //浮动层的初始位置,分别对应层的初始X坐标和Y坐标

var xin = true, yin = true //判断层的X坐标和Y坐标是否在在控制范围之内,xin为真是层向右移动,否则向左;yin为真是层向下移动,否则向上
var step = 1 //层移动的步长,值越大移动速度越快
var delay = 10 //层移动的时间间隔,单位为毫秒,值越小移动速度越快

网页特效”漂浮广告代码”来回跳动的,布布扣,bubuko.com

网页特效”漂浮广告代码”来回跳动的

标签:style   blog   c   java   tar   ext   

原文地址:http://www.cnblogs.com/wayne173/p/3741704.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!