您的位置:首页 > 运维架构 > 网站架构

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

2015-12-03 08:47 555 查看
 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";
}

 

 
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: