网站首页浮动窗口移动代码

 1.html代码:

<div id="dcwj" class="flabox" style="position:absolute;z-index:1000;">

    <div class="flatit"><span><a onclick="closediv();" title="关闭" style="cursor: pointer;">×</a></span>最新通知公告</div>

    <ul class="flaul">

    <c:forEach items="${newsInfoList}" begin="0" end="2" var="cur">

    <c:url var="url" value="/IndexNewsInfo.do?uuid=${cur.uuid}" />

      <li><a title="${fn:escapeXml(cur.title)}" style="color:${cur.title_color}; text-decoration:none; <c:if test='${cur.title_is_strong eq 1}'>font-weight:bold;</c:if>" href="${url}" target="_blank">

        <c:out value="${fnx:abbreviate(fn:escapeXml(cur.title), 2 * 15, '..')}" />

      </a></li>

    </c:forEach>

    </ul>
</div>
2.js代码:

var x = 50,y = 60;

var xin = true, yin = true;

var step = 0.5;

var delay = 10;

var obj=document.getElementById("dcwj");

var width= window.screen.availWidth;

var height = window.screen.availHeight;

function dcwj() {

    var L=T=0;

    //var R= document.body.clientWidth-obj.offsetWidth;

    var R= width-obj.offsetWidth-35;

    //var B = document.body.clientHeight-obj.offsetHeight;

    var B = height-obj.offsetHeight-100;

    obj.style.left = x + (document.documentElement.scrollLeft || document.body.scrollLeft) + "px";

    obj.style.top = y + (document.documentElement.scrollTop || 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; }

    //document.getElementById("console").innerHTML=x + " : " + y;

}

var itl;

if(obj!=null){

    itl    = setInterval("dcwj()", delay);    

    obj.onmouseover=function(){clearInterval(itl);};

    obj.onmouseout=function(){itl=setInterval("dcwj()", delay);};

}

function closediv(){

   clearInterval(itl);

   obj.style.display = "none";
}
 
 
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值