zoukankan      html  css  js  c++  java
  • 网页特效”漂浮广告代码”来回跳动的

    <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 += " 网页可见区域高:"+ document.body.clientHeight;
    s += " 网页可见区域高:"+ document.body.offsetHeight +" (包括边线的宽)";
    s += " 网页正文全文宽:"+ document.body.scrollWidth;
    s += " 网页正文全文高:"+ document.body.scrollHeight;
    s += " 网页被卷去的高:"+ document.body.scrollTop;
    s += " 网页被卷去的左:"+ document.body.scrollLeft;
    s += " 网页正文部分上:"+ window.screenTop;
    s += " 网页正文部分左:"+ window.screenLeft;
    s += " 屏幕分辨率的高:"+ window.screen.height;
    s += " 屏幕分辨率的宽:"+ window.screen.width;
    s += " 屏幕可用工作区高度:"+ window.screen.availHeight;
    s += " 屏幕可用工作区宽度:"+ 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 //层移动的时间间隔,单位为毫秒,值越小移动速度越快

  • 相关阅读:
    LeetCode OJ String to Integer (atoi) 字符串转数字
    HDU 1005 Number Sequence(AC代码)
    HDU 1004 Let the Balloon Rise(AC代码)
    HDU 1003 Max Sum(AC代码)
    012 Integer to Roman 整数转换成罗马数字
    011 Container With Most Water 盛最多水的容器
    010 Regular Expression Matching 正则表达式匹配
    007 Reverse Integer 旋转整数
    006 ZigZag Conversion
    005 Longest Palindromic Substring 最长回文子串
  • 原文地址:https://www.cnblogs.com/wayne173/p/3741704.html
Copyright © 2011-2022 走看看