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";
}